-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(Chat): Display system messages about adding/removing members immediately after an update is performed #14146
(Chat): Display system messages about adding/removing members immediately after an update is performed #14146
Conversation
Jenkins BuildsClick to see older builds (18)
|
a1798f6
to
25e60cd
Compare
var (chats, messages) = result | ||
self.signalChatsAndMessagesUpdates(chats, messages) | ||
|
||
proc processGroupChatUpdateAfterSend*(self: Service, response: RpcResponse[JsonNode]): (ChatDto, seq[MessageDto]) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proc processGroupChatUpdateAfterSend*(self: Service, response: RpcResponse[JsonNode]): (ChatDto, seq[MessageDto]) = | |
proc processGroupChatUpdateResponse*(self: Service, response: RpcResponse[JsonNode]): (ChatDto, seq[MessageDto]) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, do we actually need to return (ChatDto, seq[MessageDto])
, if we're discarding it in both usages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
let chat = chatMap[msg.chatId] | ||
self.events.emit(SIGNAL_SENDING_SUCCESS, MessageSendingSuccess(message: msg, chat: chat)) | ||
|
||
proc processMessageUpdateAfterSend*(self: Service, response: RpcResponse[JsonNode]): (seq[ChatDto], seq[MessageDto]) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's not your code, but this AfterSend
is quite weird.
The name of the function should describe what it does, not when it will be called. 😄
proc processMessageUpdateAfterSend*(self: Service, response: RpcResponse[JsonNode]): (seq[ChatDto], seq[MessageDto]) = | |
proc processMessageUpdateResponse*(self: Service, response: RpcResponse[JsonNode]): (seq[ChatDto], seq[MessageDto]) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that makes sense!
Since protocol/messenger.go
uses the MessengerResponse
type, it might be better to use the same name in proc. Something like proc processMessengerResponse*(self: Service, response: RpcResponse[JsonNode]):
.
01938c3
to
faf09f8
Compare
proc parseGroupChatResponse*(self: Service, response: RpcResponse[JsonNode]): (ChatDto, seq[MessageDto]) = | ||
var chat: ChatDto | ||
var messages: seq[MessageDto] = @[] | ||
if response.result{"chat"} != nil: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the result can be an error. Could you please log that we got an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done ✅
proc processMessageUpdateAfterSend*(self: Service, response: RpcResponse[JsonNode]): (seq[ChatDto], seq[MessageDto]) = | ||
result = self.parseChatResponse(response) | ||
var (chats, messages) = result | ||
proc parseGroupChatResponse*(self: Service, response: RpcResponse[JsonNode]): (ChatDto, seq[MessageDto]) = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need this function? I mean, the code can exist in processGroupChatUpdateAfterSend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 6 endpoints in api_group_chats.go
that return GroupChatResponse
. So I tried to follow the existing approach with parseChatReponse
.
I'm not sure if this function will be useful. Do you think it should be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is used only in one place - it make sense to put this code there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
faf09f8
to
aa916c2
Compare
fixes #9876, #10702
What does the PR do
chats/service.nim
addGroupMembers
/removeMemberFromGroupChat
now analyzes and processes theGroupChatResponse
processMessageUpdateAfterSend
, the procedureprocessGroupChatUpdateAfterSend
has been added. Now they both use thesignalChatsAndMessagesUpdates
proc, which emits signals to notify UI of new chats/messagesparseGroupChatResponse
method to parse GroupChatResponse, since this structure has 'chat' and ChatResponse has 'chats'Screenshot of functionality (including design for comparison)
system_messages.mp4