fix: load old user status, and fix code review obs.
This commit is contained in:
parent
7aaca9ec4d
commit
07c399530b
|
@ -9,7 +9,12 @@ import # status-desktop libs
|
||||||
proc handleChatEvents(self: ChatController) =
|
proc handleChatEvents(self: ChatController) =
|
||||||
# Display already saved messages
|
# Display already saved messages
|
||||||
self.status.events.on("messagesLoaded") do(e:Args):
|
self.status.events.on("messagesLoaded") do(e:Args):
|
||||||
self.view.pushMessages(MsgsLoadedArgs(e).messages)
|
let evArgs = MsgsLoadedArgs(e)
|
||||||
|
self.view.pushMessages(evArgs.messages)
|
||||||
|
for statusUpdate in evArgs.statusUpdates:
|
||||||
|
echo "updating member visibility", $statusUpdate
|
||||||
|
self.view.communities.updateMemberVisibility(statusUpdate)
|
||||||
|
|
||||||
# Display emoji reactions
|
# Display emoji reactions
|
||||||
self.status.events.on("reactionsLoaded") do(e:Args):
|
self.status.events.on("reactionsLoaded") do(e:Args):
|
||||||
self.view.reactions.push(ReactionsLoadedArgs(e).reactions)
|
self.view.reactions.push(ReactionsLoadedArgs(e).reactions)
|
||||||
|
@ -34,7 +39,7 @@ proc handleChatEvents(self: ChatController) =
|
||||||
self.view.updateChats(evArgs.chats)
|
self.view.updateChats(evArgs.chats)
|
||||||
self.view.pushMessages(evArgs.messages)
|
self.view.pushMessages(evArgs.messages)
|
||||||
|
|
||||||
# TODO: update current user status
|
# TODO: update current user status (once it's possible to switch between ONLINE and DO_NOT_DISTURB)
|
||||||
|
|
||||||
for statusUpdate in evArgs.statusUpdates:
|
for statusUpdate in evArgs.statusUpdates:
|
||||||
self.view.communities.updateMemberVisibility(statusUpdate)
|
self.view.communities.updateMemberVisibility(statusUpdate)
|
||||||
|
@ -120,6 +125,7 @@ proc handleChatEvents(self: ChatController) =
|
||||||
self.view.setActiveChannel(channel.chat.id)
|
self.view.setActiveChannel(channel.chat.id)
|
||||||
self.status.chat.chatMessages(channel.chat.id)
|
self.status.chat.chatMessages(channel.chat.id)
|
||||||
self.status.chat.chatReactions(channel.chat.id)
|
self.status.chat.chatReactions(channel.chat.id)
|
||||||
|
self.status.chat.statusUpdates()
|
||||||
|
|
||||||
self.status.events.on("channelLeft") do(e: Args):
|
self.status.events.on("channelLeft") do(e: Args):
|
||||||
let chatId = ChatIdArg(e).chatId
|
let chatId = ChatIdArg(e).chatId
|
||||||
|
|
|
@ -380,7 +380,8 @@ QtObject:
|
||||||
result = fmt"Error inviting to the community: {e.msg}"
|
result = fmt"Error inviting to the community: {e.msg}"
|
||||||
|
|
||||||
proc inviteUsersToCommunity*(self: CommunitiesView, pubKeysJSON: string): string {.slot.} =
|
proc inviteUsersToCommunity*(self: CommunitiesView, pubKeysJSON: string): string {.slot.} =
|
||||||
self.inviteUsersToCommunityById(self.activeCommunity.id(), pubKeysJSON)
|
result = self.inviteUsersToCommunityById(self.activeCommunity.id(), pubKeysJSON)
|
||||||
|
self.status.chat.statusUpdates()
|
||||||
|
|
||||||
proc exportCommunity*(self: CommunitiesView): string {.slot.} =
|
proc exportCommunity*(self: CommunitiesView): string {.slot.} =
|
||||||
try:
|
try:
|
||||||
|
@ -441,6 +442,7 @@ QtObject:
|
||||||
try:
|
try:
|
||||||
self.status.chat.acceptRequestToJoinCommunity(requestId)
|
self.status.chat.acceptRequestToJoinCommunity(requestId)
|
||||||
self.removeMembershipRequest(requestId, true)
|
self.removeMembershipRequest(requestId, true)
|
||||||
|
self.status.chat.statusUpdates()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "Error accepting request to join the community", msg = e.msg
|
error "Error accepting request to join the community", msg = e.msg
|
||||||
return "Error accepting request to join the community"
|
return "Error accepting request to join the community"
|
||||||
|
|
|
@ -179,7 +179,7 @@ QtObject:
|
||||||
community.memberStatus[statusUpdate.publicKey] = statusUpdate
|
community.memberStatus[statusUpdate.publicKey] = statusUpdate
|
||||||
else:
|
else:
|
||||||
community.memberStatus[statusUpdate.publicKey] = statusUpdate
|
community.memberStatus[statusUpdate.publicKey] = statusUpdate
|
||||||
break
|
|
||||||
|
|
||||||
proc addChannelToCommunity*(self: CommunityList, communityId: string, chat: Chat) =
|
proc addChannelToCommunity*(self: CommunityList, communityId: string, chat: Chat) =
|
||||||
var community = self.getCommunityById(communityId)
|
var community = self.getCommunityById(communityId)
|
||||||
|
|
|
@ -318,6 +318,7 @@ QtObject:
|
||||||
trace "Loading more messages", chaId = self.channelView.activeChannel.id
|
trace "Loading more messages", chaId = self.channelView.activeChannel.id
|
||||||
self.status.chat.chatMessages(self.channelView.activeChannel.id, false)
|
self.status.chat.chatMessages(self.channelView.activeChannel.id, false)
|
||||||
self.status.chat.chatReactions(self.channelView.activeChannel.id, false)
|
self.status.chat.chatReactions(self.channelView.activeChannel.id, false)
|
||||||
|
self.status.chat.statusUpdates()
|
||||||
self.messagesLoaded();
|
self.messagesLoaded();
|
||||||
|
|
||||||
proc loadMoreMessagesWithIndex*(self: MessageView, channelIndex: int) {.slot.} =
|
proc loadMoreMessagesWithIndex*(self: MessageView, channelIndex: int) {.slot.} =
|
||||||
|
@ -327,6 +328,7 @@ QtObject:
|
||||||
trace "Loading more messages", chaId = selectedChannel.id
|
trace "Loading more messages", chaId = selectedChannel.id
|
||||||
self.status.chat.chatMessages(selectedChannel.id, false)
|
self.status.chat.chatMessages(selectedChannel.id, false)
|
||||||
self.status.chat.chatReactions(selectedChannel.id, false)
|
self.status.chat.chatReactions(selectedChannel.id, false)
|
||||||
|
self.status.chat.statusUpdates()
|
||||||
self.messagesLoaded();
|
self.messagesLoaded();
|
||||||
|
|
||||||
proc loadingMessagesChanged*(self: MessageView, value: bool) {.signal.}
|
proc loadingMessagesChanged*(self: MessageView, value: bool) {.signal.}
|
||||||
|
|
|
@ -44,6 +44,7 @@ type
|
||||||
|
|
||||||
MsgsLoadedArgs* = ref object of Args
|
MsgsLoadedArgs* = ref object of Args
|
||||||
messages*: seq[Message]
|
messages*: seq[Message]
|
||||||
|
statusUpdates*: seq[StatusUpdate]
|
||||||
|
|
||||||
ActivityCenterNotificationsArgs* = ref object of Args
|
ActivityCenterNotificationsArgs* = ref object of Args
|
||||||
activityCenterNotifications*: seq[ActivityCenterNotification]
|
activityCenterNotifications*: seq[ActivityCenterNotification]
|
||||||
|
@ -286,6 +287,10 @@ proc chatMessages*(self: ChatModel, chatId: string, initialLoad:bool = true) =
|
||||||
self.events.emit("messagesLoaded", MsgsLoadedArgs(messages: messageTuple[1]))
|
self.events.emit("messagesLoaded", MsgsLoadedArgs(messages: messageTuple[1]))
|
||||||
|
|
||||||
|
|
||||||
|
proc statusUpdates*(self: ChatModel) =
|
||||||
|
let statusUpdates = status_chat.statusUpdates()
|
||||||
|
self.events.emit("messagesLoaded", MsgsLoadedArgs(statusUpdates: statusUpdates))
|
||||||
|
|
||||||
proc chatMessages*(self: ChatModel, chatId: string, initialLoad:bool = true, cursor: string = "", messages: seq[Message]) =
|
proc chatMessages*(self: ChatModel, chatId: string, initialLoad:bool = true, cursor: string = "", messages: seq[Message]) =
|
||||||
if not self.msgCursor.hasKey(chatId):
|
if not self.msgCursor.hasKey(chatId):
|
||||||
self.msgCursor[chatId] = "";
|
self.msgCursor[chatId] = "";
|
||||||
|
|
|
@ -89,6 +89,12 @@ proc parseActivityCenterNotifications*(rpcResult: JsonNode): (string, seq[Activi
|
||||||
notifs.add(jsonMsg.toActivityCenterNotification())
|
notifs.add(jsonMsg.toActivityCenterNotification())
|
||||||
return (rpcResult{"cursor"}.getStr, notifs)
|
return (rpcResult{"cursor"}.getStr, notifs)
|
||||||
|
|
||||||
|
proc statusUpdates*(): seq[StatusUpdate] =
|
||||||
|
let rpcResult = callPrivateRPC("statusUpdates".prefix, %* []).parseJson()["result"]
|
||||||
|
if rpcResult != nil and rpcResult{"statusUpdates"} != nil and rpcResult["statusUpdates"].len != 0:
|
||||||
|
for jsonStatusUpdate in rpcResult["statusUpdates"]:
|
||||||
|
result.add(jsonStatusUpdate.toStatusUpdate)
|
||||||
|
|
||||||
proc rpcChatMessages*(chatId: string, cursorVal: JsonNode, limit: int, success: var bool): string =
|
proc rpcChatMessages*(chatId: string, cursorVal: JsonNode, limit: int, success: var bool): string =
|
||||||
success = true
|
success = true
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -144,7 +144,9 @@ Item {
|
||||||
isSwitch: true
|
isSwitch: true
|
||||||
switchChecked: profileModel.profile.sendUserStatus
|
switchChecked: profileModel.profile.sendUserStatus
|
||||||
onClicked: function (checked) {
|
onClicked: function (checked) {
|
||||||
profileModel.setSendUserStatus(checked)
|
if (profileModel.profile.sendUserStatus !== checked) {
|
||||||
|
profileModel.setSendUserStatus(checked)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue