core: update version response (#1819)

* core: update version response

* add simplexmq commit and version to version info

* refactor
This commit is contained in:
Evgeny Poberezkin
2023-01-22 15:16:45 +00:00
committed by GitHub
parent 8ff8f9d695
commit 114b76e3f8
5 changed files with 46 additions and 9 deletions
+10 -1
View File
@@ -112,7 +112,7 @@ responseToView user_ ChatConfig {logLevel, testView} liveItems ts = \case
CRFileTransferStatus ftStatus -> viewFileTransferStatus ftStatus
CRUserProfile p -> viewUserProfile p
CRUserProfileNoChange -> ["user profile did not change"]
CRVersionInfo _ _ -> [plain versionStr, plain updateStr]
CRVersionInfo info -> viewVersionInfo logLevel info
CRChatCmdError e -> viewChatError logLevel e
CRInvitation cReq -> viewConnReqInvitation cReq
CRSentConfirmation -> ["confirmation sent!"]
@@ -1142,6 +1142,15 @@ instance ToJSON WCallCommand where
toEncoding = J.genericToEncoding . taggedObjectJSON $ dropPrefix "WCCall"
toJSON = J.genericToJSON . taggedObjectJSON $ dropPrefix "WCCall"
viewVersionInfo :: ChatLogLevel -> CoreVersionInfo -> [StyledString]
viewVersionInfo logLevel CoreVersionInfo {version, buildTimestamp, simplexmqVersion, simplexmqCommit} =
map plain $
if logLevel <= CLLInfo
then [versionString version <> parens buildTimestamp, updateStr, "simplexmq: " <> simplexmqVersion <> parens simplexmqCommit]
else [versionString version, updateStr]
where
parens s = " (" <> s <> ")"
viewChatError :: ChatLogLevel -> ChatError -> [StyledString]
viewChatError logLevel = \case
ChatError err -> case err of