Skip to content
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

Merged
merged 3 commits into from
Mar 26, 2024

Conversation

friofry
Copy link
Contributor

@friofry friofry commented Mar 25, 2024

fixes #9876, #10702

What does the PR do

chats/service.nim

  1. addGroupMembers/removeMemberFromGroupChat now analyzes and processes the GroupChatResponse
  2. Similarly to the processMessageUpdateAfterSend, the procedure processGroupChatUpdateAfterSend has been added. Now they both use the signalChatsAndMessagesUpdates proc, which emits signals to notify UI of new chats/messages
  3. Added a separate parseGroupChatResponse method to parse GroupChatResponse, since this structure has 'chat' and ChatResponse has 'chats'

Screenshot of functionality (including design for comparison)

system_messages.mp4

@status-im-auto
Copy link
Member

status-im-auto commented Mar 25, 2024

Jenkins Builds

Click to see older builds (18)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ a1798f6 #1 2024-03-25 14:06:47 ~6 min tests/nim 📄log
✔️ a1798f6 #1 2024-03-25 14:07:59 ~7 min macos/aarch64 🍎dmg
✔️ a1798f6 #1 2024-03-25 14:10:41 ~10 min macos/x86_64 🍎dmg
a1798f6 #1 2024-03-25 14:11:08 ~10 min tests/ui 📄log
✔️ a1798f6 #1 2024-03-25 14:16:53 ~16 min linux/x86_64 📦tgz
✔️ 25e60cd #2 2024-03-25 14:34:17 ~6 min macos/aarch64 🍎dmg
✔️ 25e60cd #2 2024-03-25 14:34:52 ~6 min tests/nim 📄log
✔️ 25e60cd #2 2024-03-25 14:36:32 ~8 min macos/x86_64 🍎dmg
✔️ 25e60cd #2 2024-03-25 14:39:17 ~11 min tests/ui 📄log
✔️ 25e60cd #2 2024-03-25 14:43:30 ~15 min linux/x86_64 📦tgz
✔️ 369a41e #3 2024-03-25 14:56:49 ~6 min tests/nim 📄log
✔️ 369a41e #3 2024-03-25 14:57:32 ~7 min macos/x86_64 🍎dmg
✔️ 01938c3 #5 2024-03-25 15:04:26 ~4 min macos/aarch64 🍎dmg
✔️ 01938c3 #5 2024-03-25 15:06:54 ~7 min tests/nim 📄log
✔️ 01938c3 #5 2024-03-25 15:09:44 ~10 min macos/x86_64 🍎dmg
✔️ 01938c3 #5 2024-03-25 15:10:18 ~10 min tests/ui 📄log
✔️ 01938c3 #5 2024-03-25 15:14:51 ~15 min linux/x86_64 📦tgz
✔️ 01938c3 #5 2024-03-25 15:30:48 ~31 min windows/x86_64 💿exe
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ faf09f8 #6 2024-03-25 16:56:09 ~5 min macos/aarch64 🍎dmg
✔️ faf09f8 #6 2024-03-25 16:57:55 ~6 min tests/nim 📄log
✔️ faf09f8 #6 2024-03-25 16:58:50 ~7 min macos/x86_64 🍎dmg
✔️ faf09f8 #6 2024-03-25 17:03:00 ~12 min tests/ui 📄log
✔️ faf09f8 #6 2024-03-25 17:07:44 ~16 min linux/x86_64 📦tgz
✔️ faf09f8 #6 2024-03-25 17:19:30 ~28 min windows/x86_64 💿exe
✔️ aa916c2 #7 2024-03-26 13:09:58 ~5 min macos/aarch64 🍎dmg
✔️ aa916c2 #7 2024-03-26 13:11:46 ~6 min tests/nim 📄log
✔️ aa916c2 #7 2024-03-26 13:13:16 ~8 min macos/x86_64 🍎dmg
✔️ aa916c2 #7 2024-03-26 13:17:30 ~12 min tests/ui 📄log
✔️ aa916c2 #7 2024-03-26 13:19:23 ~14 min linux/x86_64 📦tgz
✔️ aa916c2 #7 2024-03-26 13:37:40 ~32 min windows/x86_64 💿exe

@friofry friofry changed the title (Chat): Display system add/remove messages immediately after update (Chat): Display system messages about adding/removing members immediately after an update is performed Mar 25, 2024
@friofry friofry force-pushed the ab/issue-9867-display-add-remove-messages-in-chat branch from a1798f6 to 25e60cd Compare March 25, 2024 14:27
var (chats, messages) = result
self.signalChatsAndMessagesUpdates(chats, messages)

proc processGroupChatUpdateAfterSend*(self: Service, response: RpcResponse[JsonNode]): (ChatDto, seq[MessageDto]) =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
proc processGroupChatUpdateAfterSend*(self: Service, response: RpcResponse[JsonNode]): (ChatDto, seq[MessageDto]) =
proc processGroupChatUpdateResponse*(self: Service, response: RpcResponse[JsonNode]): (ChatDto, seq[MessageDto]) =

Copy link
Contributor

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?

Copy link
Contributor Author

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]) =
Copy link
Contributor

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. 😄

Suggested change
proc processMessageUpdateAfterSend*(self: Service, response: RpcResponse[JsonNode]): (seq[ChatDto], seq[MessageDto]) =
proc processMessageUpdateResponse*(self: Service, response: RpcResponse[JsonNode]): (seq[ChatDto], seq[MessageDto]) =

Copy link
Contributor Author

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]): .

proc parseGroupChatResponse*(self: Service, response: RpcResponse[JsonNode]): (ChatDto, seq[MessageDto]) =
var chat: ChatDto
var messages: seq[MessageDto] = @[]
if response.result{"chat"} != nil:
Copy link
Contributor

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?

Copy link
Contributor Author

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]) =
Copy link
Contributor

@mprakhov mprakhov Mar 25, 2024

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

Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

@mprakhov mprakhov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@friofry friofry force-pushed the ab/issue-9867-display-add-remove-messages-in-chat branch from faf09f8 to aa916c2 Compare March 26, 2024 13:04
@friofry friofry merged commit c53e4ae into master Mar 26, 2024
8 checks passed
@friofry friofry deleted the ab/issue-9867-display-add-remove-messages-in-chat branch March 26, 2024 14:13
kounkou pushed a commit that referenced this pull request Apr 4, 2024
…tely after an update is performed (#14146)

* (Chat): Display system add/remove messages immediately after update

fixes #9876

* (Chat): Display system "pinned" message immediately after update

fixes #10702

* fix issues from the PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Chats: If you remove/add user from the group chat, system message will be displayed only after app restart
5 participants