mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-22 17:31:55 +00:00
core, ui: badge redeem errors and fixes (#7515)
- redeem errors are typed (CEBadgeRedeemError) instead of matched by text in the apps - service timeout (A_SERVICE) decodes in the apps and offers Retry via the existing retry alert - unexpected redeem errors show the error itself instead of a generic message - service error codes are a typed enum in the apps (BadgeServiceErrorCode) - CRBadgeRedeemed returns badge state, so the apps skip a second round-trip after redeem - setBadgeAlertAcked is scoped to user_id - badgeChanged updates non-active profiles, so other profiles' badges don't go stale - pitch banner is not shown to a profile that already has a badge - one badgeTypeName per platform, used by the badge screen and the badge info alert - BadgeAlertKind and BadgeAlertPrice decode via standard JSON, no custom decoders - dead "Support ended" title branch removed from Your Badge view - kotlin: users from badge responses carry remoteHostId - kotlin: redeem code field keeps the IME's cursor and composition state - kotlin: "Get your code" shown in all flavours - kotlin: "Don't show again" -> "Dismiss", matching iOS - kotlin: parseBadgeCode moved next to its FFI in platform/Core.kt - kotlin: BadgesView no longer cross-fades on badge state updates - kotlin: section title not uppercased - ios: redeem code field parses once per change - ios: A_SERVICE rejected reason is not decoded - CLI: "cannot redeem badge code: ..." with the source of the error - comments clarified
This commit is contained in:
1 parent
9af6fb00e6
commit
f38c7e0f2b
26 files changed
+482
-434
No files matched your search
@@ -41,7 +41,7 @@ import Numeric (showFFloat)
|
||||
import Simplex.Chat.Call
|
||||
import Simplex.Chat.Controller
|
||||
import Simplex.Chat.Help
|
||||
import Simplex.Chat.Library.Commands (maxImageSize)
|
||||
import Simplex.Chat.Library.Commands (badgeServiceErrorText, maxImageSize)
|
||||
import Simplex.Chat.Markdown
|
||||
import Simplex.Chat.Badges (BadgeInfo (..), BadgeStatus (..), BadgeType (..), LocalBadge, localBadgeInfo, localBadgeStatus)
|
||||
import Simplex.Chat.Badges.Types (BadgeAlert (..), BadgeState (..))
|
||||
@@ -190,7 +190,7 @@ chatResponseToView hu cfg@ChatConfig {logLevel, showReactions, showFullLinks, te
|
||||
CRServiceResponse u resp -> ttyUser u ["service response: " <> viewJSON resp]
|
||||
CRServiceReplyAccepted u (AgentConnId cId) -> ttyUser u [plain $ "service reply accepted, connection id: " <> safeDecodeUtf8 (strEncode cId)]
|
||||
-- the badge is only shown when it is the one now on the profile; a replayed code's badge may not be
|
||||
CRBadgeRedeemed u badge newBadge -> ttyUser u $ if newBadge then "badge redeemed" : viewContactBadge (Just badge) else ["badge already redeemed"]
|
||||
CRBadgeRedeemed u badge newBadge _ -> ttyUser u $ if newBadge then "badge redeemed" : viewContactBadge (Just badge) else ["badge already redeemed"]
|
||||
CRBadgeState u st -> ttyUser u $ viewUserBadgeState st
|
||||
CRGroupCreated u g -> ttyUser u $ viewGroupCreated g testView
|
||||
CRPublicGroupCreated u g _groupLink _relays -> ttyUser u $ viewGroupCreated g testView
|
||||
@@ -2841,6 +2841,16 @@ viewChatError isCmd logLevel testView = \case
|
||||
CEAgentNoSubResult connId -> ["no subscription result for connection: " <> sShow connId]
|
||||
CEServerProtocol p -> [plain $ "Servers for protocol " <> strEncode p <> " cannot be configured by the users"]
|
||||
CECommandError e -> ["bad chat command: " <> plain e]
|
||||
CEBadgeRedeemError e ->
|
||||
let reason = case e of
|
||||
BREInvalidCode -> "invalid code"
|
||||
BREServiceNotConfigured -> "badge service not configured"
|
||||
BREBadgeActive -> "badge already active"
|
||||
BREServiceError code -> "badge service error: " <> T.unpack (badgeServiceErrorText code)
|
||||
BREInvalidResponse m -> "invalid service response: " <> m
|
||||
BREUnknownKeyIndex -> "credential names an unknown badge key index"
|
||||
BRECredentialNotVerified -> "credential does not verify against configured key"
|
||||
in ["cannot redeem badge code: " <> plain reason]
|
||||
CEAgentCommandError e -> ["agent command error: " <> plain e]
|
||||
CEInvalidFileDescription e -> ["invalid file description: " <> plain e]
|
||||
CEConnectionIncognitoChangeProhibited -> ["incognito mode change prohibited"]
|
||||
|
||||
Reference in new issue
Block a user