From 7ca3084dde164d65b692faba56f8d534916bee23 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 30 Mar 2023 15:46:08 -0400 Subject: [PATCH] fix(edit): fix mentions in edits not counting towards the badge Fixes #10077 The fix itself is in the status-go PR. The desktop changes are just to clean up the old code that no longer worked --- .../chat_content/messages/controller.nim | 4 ---- .../chat_content/messages/module.nim | 3 --- .../modules/main/chat_section/controller.nim | 4 ---- .../main/chat_section/io_interface.nim | 3 --- src/app/modules/main/chat_section/module.nim | 21 ------------------- src/app/modules/main/io_interface.nim | 3 --- src/app/modules/main/module.nim | 3 --- .../modules/shared_models/section_model.nim | 12 ----------- src/app_service/service/message/service.nim | 7 ------- 9 files changed, 60 deletions(-) diff --git a/src/app/modules/main/chat_section/chat_content/messages/controller.nim b/src/app/modules/main/chat_section/chat_content/messages/controller.nim index 86b069136c..872e7e2922 100644 --- a/src/app/modules/main/chat_section/chat_content/messages/controller.nim +++ b/src/app/modules/main/chat_section/chat_content/messages/controller.nim @@ -313,9 +313,5 @@ proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAcco proc leaveChat*(self: Controller) = self.chatService.leaveChat(self.chatId) -method checkEditedMessageForMentions*(self: Controller, chatId: string, - editedMessage: MessageDto, oldMentions: seq[string]) = - self.messageService.checkEditedMessageForMentions(chatId, editedMessage, oldMentions) - method resendChatMessage*(self: Controller, messageId: string): string = return self.messageService.resendChatMessage(messageId) diff --git a/src/app/modules/main/chat_section/chat_content/messages/module.nim b/src/app/modules/main/chat_section/chat_content/messages/module.nim index 02a76933d1..402bc8c581 100644 --- a/src/app/modules/main/chat_section/chat_content/messages/module.nim +++ b/src/app/modules/main/chat_section/chat_content/messages/module.nim @@ -603,9 +603,6 @@ method onMessageEdited*(self: Module, message: MessageDto) = message.mentionedUsersPks ) - # ask service to send SIGNAL_MENTIONED_IN_EDITED_MESSAGE signal if there is a new user's mention - self.controller.checkEditedMessageForMentions(self.getChatId(), message, mentionedUsersPks) - method onHistoryCleared*(self: Module) = self.view.model().clear() diff --git a/src/app/modules/main/chat_section/controller.nim b/src/app/modules/main/chat_section/controller.nim index 9583787afc..b8635f6d50 100644 --- a/src/app/modules/main/chat_section/controller.nim +++ b/src/app/modules/main/chat_section/controller.nim @@ -136,10 +136,6 @@ proc init*(self: Controller) = self.delegate.onNewMessagesReceived(args.sectionId, args.chatId, args.chatType, args.lastMessageTimestamp, args.unviewedMessagesCount, args.unviewedMentionsCount, args.messages[0]) - self.events.on(message_service.SIGNAL_MENTIONED_IN_EDITED_MESSAGE) do(e: Args): - let args = MessageEditedArgs(e) - self.delegate.onMeMentionedInEditedMessage(args.chatId, args.message) - self.events.on(chat_service.SIGNAL_CHAT_MUTED) do(e:Args): let args = chat_service.ChatArgs(e) self.delegate.onChatMuted(args.chatId) diff --git a/src/app/modules/main/chat_section/io_interface.nim b/src/app/modules/main/chat_section/io_interface.nim index c82635e1c1..7c769439e9 100644 --- a/src/app/modules/main/chat_section/io_interface.nim +++ b/src/app/modules/main/chat_section/io_interface.nim @@ -325,9 +325,6 @@ method reorderCommunityCategories*(self: AccessInterface, categoryId: string, po method reorderCommunityChat*(self: AccessInterface, categoryId: string, chatId: string, position: int): string = raise newException(ValueError, "No implementation available") -method onMeMentionedInEditedMessage*(self: AccessInterface, chatId: string, editedMessage : MessageDto) {.base.} = - raise newException(ValueError, "No implementation available") - method downloadMessages*(self: AccessInterface, chatId: string, filePath: string) = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index b5dd11e79f..6e33c4c3f1 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -482,9 +482,6 @@ proc updateParentBadgeNotifications(self: Module) = unviewedMentionsCount ) -proc incrementParentBadgeNotifications(self: Module) = - self.delegate.onNotificationsIncremented(self.controller.getMySectionId()) - proc updateBadgeNotifications(self: Module, chatId: string, hasUnreadMessages: bool, unviewedMentionsCount: int) = # update model of this module (appropriate chat from the chats list (chats model)) self.view.chatsModel().updateNotificationsForItemById(chatId, hasUnreadMessages, unviewedMentionsCount) @@ -494,15 +491,6 @@ proc updateBadgeNotifications(self: Module, chatId: string, hasUnreadMessages: b # update parent module self.updateParentBadgeNotifications() -proc incrementBadgeNotifications(self: Module, chatId: string) = - if self.chatsLoaded: - let notificationCount = self.view.chatsModel().incrementNotificationsForItemByIdAndGetNotificationCount(chatId) - # update child module - if (self.chatContentModules.contains(chatId)): - self.chatContentModules[chatId].onNotificationsUpdated(hasUnreadMessages = true, notificationCount) - # update parent module - self.incrementParentBadgeNotifications() - method updateLastMessageTimestamp*(self: Module, chatId: string, lastMessageTimestamp: int) = self.view.chatsModel().updateLastMessageTimestampOnItemById(chatId, lastMessageTimestamp) @@ -965,15 +953,6 @@ method onNewMessagesReceived*(self: Module, sectionIdMsgBelongsTo: string, chatI message.id, notificationType.int, chatTypeMsgBelongsTo == ChatType.OneToOne, chatTypeMsgBelongsTo == ChatType.PrivateGroupChat) -method onMeMentionedInEditedMessage*(self: Module, chatId: string, editedMessage : MessageDto) = - if((editedMessage.communityId.len == 0 and - self.controller.getMySectionId() != singletonInstance.userProfile.getPubKey()) or - (editedMessage.communityId.len > 0 and - self.controller.getMySectionId() != editedMessage.communityId)): - return - - self.incrementBadgeNotifications(chatId) - method addGroupMembers*(self: Module, chatId: string, pubKeys: string) = self.controller.addGroupMembers(chatId, self.convertPubKeysToJson(pubKeys)) diff --git a/src/app/modules/main/io_interface.nim b/src/app/modules/main/io_interface.nim index 23234ee518..9d2d16ad56 100644 --- a/src/app/modules/main/io_interface.nim +++ b/src/app/modules/main/io_interface.nim @@ -123,9 +123,6 @@ method onNotificationsUpdated*(self: AccessInterface, sectionId: string, section sectionNotificationCount: int) {.base.} = raise newException(ValueError, "No implementation available") -method onNotificationsIncremented*(self: AccessInterface, sectionId: string) {.base.} = - raise newException(ValueError, "No implementation available") - method onNotificationsIncreased*(self: AccessInterface, sectionId: string, addedSectionNotificationCount: bool, sectionNotificationCount: int) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/module.nim b/src/app/modules/main/module.nim index 3a3d6fa859..2f5f52769e 100644 --- a/src/app/modules/main/module.nim +++ b/src/app/modules/main/module.nim @@ -827,9 +827,6 @@ method onNotificationsUpdated[T](self: Module[T], sectionId: string, sectionHasU sectionNotificationCount: int) = self.view.model().updateNotifications(sectionId, sectionHasUnreadMessages, sectionNotificationCount) -method onNotificationsIncremented[T](self: Module[T], sectionId: string) = - self.view.model().incrementNotifications(sectionId) - method onNetworkConnected[T](self: Module[T]) = self.view.setConnected(true) diff --git a/src/app/modules/shared_models/section_model.nim b/src/app/modules/shared_models/section_model.nim index 7f2ec1bd6d..036b55d81b 100644 --- a/src/app/modules/shared_models/section_model.nim +++ b/src/app/modules/shared_models/section_model.nim @@ -397,18 +397,6 @@ QtObject: self.notificationsCountChanged() return - proc incrementNotifications*(self: SectionModel, id: string) = - let index = self.getItemIndex(id) - if (index == -1): - return - - self.items[index].hasNotification = true - self.items[index].notificationsCount = self.items[index].notificationsCount + 1 - let modelIndex = self.createIndex(index, 0, nil) - defer: modelIndex.delete - self.dataChanged(modelIndex, modelIndex, @[ModelRole.HasNotification.int, ModelRole.NotificationsCount.int]) - self.notificationsCountChanged() - proc appendCommunityToken*(self: SectionModel, id: string, item: TokenItem) = for i in 0 ..< self.items.len: if(self.items[i].id == id): diff --git a/src/app_service/service/message/service.nim b/src/app_service/service/message/service.nim index 7a36b5c7af..10ba4ab2c1 100644 --- a/src/app_service/service/message/service.nim +++ b/src/app_service/service/message/service.nim @@ -55,7 +55,6 @@ const SIGNAL_MESSAGE_EDITED* = "messageEdited" const SIGNAL_ENVELOPE_SENT* = "envelopeSent" const SIGNAL_ENVELOPE_EXPIRED* = "envelopeExpired" const SIGNAL_MESSAGE_LINK_PREVIEW_DATA_LOADED* = "messageLinkPreviewDataLoaded" -const SIGNAL_MENTIONED_IN_EDITED_MESSAGE* = "mentionedInEditedMessage" const SIGNAL_RELOAD_MESSAGES* = "reloadMessages" include async_tasks @@ -829,12 +828,6 @@ proc editMessage*(self: Service, messageId: string, contentType: int, msg: strin proc getWalletAccounts*(self: Service): seq[wallet_account_service.WalletAccountDto] = return self.walletAccountService.getWalletAccounts() -proc checkEditedMessageForMentions*(self: Service, chatId: string, editedMessage: MessageDto, oldMentions: seq[string]) = - let myPubKey = singletonInstance.userProfile.getPubKey() - if not oldMentions.contains(myPubKey) and editedMessage.mentionedUsersPks().contains(myPubKey): - let data = MessageEditedArgs(chatId: chatId, message: editedMessage) - self.events.emit(SIGNAL_MENTIONED_IN_EDITED_MESSAGE, data) - proc resendChatMessage*(self: Service, messageId: string): string = try: let response = status_go.resendChatMessage(messageId)