refactor(@activity_center): Add switch to section/chat

fixes #4474
This commit is contained in:
Anthony Laibe 2022-02-02 15:25:30 +01:00 committed by Iuri Matias
parent b688a5a305
commit b164b088f5
6 changed files with 25 additions and 18 deletions

View File

@ -113,4 +113,7 @@ method getRenderedText*[T](self: Controller[T], parsedTextArray: seq[ParsedText]
return self.messageService.getRenderedText(parsedTextArray)
method decodeContentHash*[T](self: Controller[T], hash: string): string =
return eth_utils.decodeContentHash(hash)
return eth_utils.decodeContentHash(hash)
method switchTo*[T](self: Controller[T], sectionId, chatId, messageId: string) =
self.messageService.switchTo(sectionId, chatId, messageId)

View File

@ -42,10 +42,13 @@ method dismissActivityCenterNotifications*(self: AccessInterface, notificationId
method getRenderedText*(self: AccessInterface, parsedTextArray: seq[ParsedText]): string {.base.} =
raise newException(ValueError, "No implementation available")
method decodeContentHash*(self: AccessInterface, hash: string): string {.base.} =
raise newException(ValueError, "No implementation available")
method switchTo*(self: AccessInterface, sectionId, chatId, messageId: string) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.

View File

@ -66,6 +66,9 @@ method acceptActivityCenterNotifications*(self: AccessInterface, notificationIds
method dismissActivityCenterNotifications*(self: AccessInterface, notificationIds: seq[string]): string {.base.} =
raise newException(ValueError, "No implementation available")
method switchTo*(self: AccessInterface, sectionId, chatId, messageId: string) {.base.} =
raise newException(ValueError, "No implementation available")
type
## Abstract class (concept) which must be implemented by object/s used in this
## module.

View File

@ -181,3 +181,6 @@ method dismissActivityCenterNotificationsDone*[T](self: Module[T], notificationI
method dismissActivityCenterNotifications*[T](self: Module[T], notificationIds: seq[string]): string =
self.controller.dismissActivityCenterNotifications(notificationIds)
method switchTo*[T](self: Module[T], sectionId, chatId, messageId: string) =
self.controller.switchTo(sectionId, chatId, messageId)

View File

@ -126,3 +126,6 @@ QtObject:
# self.communities.joinedCommunityList.decrementMentions(communityId, activityCenterNotification.chatId)
self.model.addActivityNotificationItemToList(activityCenterNotification)
self.activityNotificationsChanged()
proc switchTo*(self: View, sectionId: string, chatId: string, messageId: string) {.slot.} =
self.delegate.switchTo(sectionId, chatId, messageId)

View File

@ -124,12 +124,11 @@ Item {
messageImage: model.message.messageImage
messageTimestamp: model.timestamp
linkUrls: model.links
//timestamp: model.message.timestamp
messageOutgoingStatus: model.message.outgoingStatus
messageContentType: model.message.contentType
//pinnedMessage: model.message.pinned
//messagePinnedBy: model.message.pinnedBy
//reactionsModel: model.message.reactions
pinnedMessage: model.message.pinned
messagePinnedBy: model.message.pinnedBy
reactionsModel: model.message.reactions
activityCenterMessage: true
read: model.read
onImageClicked: Global.openImagePopup(image, root.messageContextMenu)
@ -140,18 +139,11 @@ Item {
}
activityCenter.close()
// if (model.message.communityId) {
// root.chatSectionModule..communities.setActiveCommunity(model.message.communityId)
// }
// root.chatSectionModule.setActiveChannel(model.chatId);
// To position to appropriate message check how it's done in AppSearch module,
// similar may be done here, corresponding module for activity center just need to
// use the mechanism done there, send the signal form message service and
// and the rest is already handled.
// positionAtMessage(model.id);
var sectionId = "chat"
if (model.message.communityId) {
sectionId = model.message.communityId
}
root.store.activityCenterModuleInst.switchTo(sectionId, model.chatId, model.id)
}
prevMessageIndex: root.previousNotificationIndex
prevMsgTimestamp: root.previousNotificationTimestamp