diff --git a/src/app/chat/view.nim b/src/app/chat/view.nim index 5200295a20..bb401cae1e 100644 --- a/src/app/chat/view.nim +++ b/src/app/chat/view.nim @@ -516,7 +516,7 @@ QtObject: self.messageList[msg.chatId].changeMessagePinned(msg.id, true, msg.pinnedBy) proc pushActivityCenterNotifications*(self:ChatsView, activityCenterNotifications: seq[ActivityCenterNotification]) = - self.activityNotificationList.setNewData(activityCenterNotifications) + self.activityNotificationList.addActivityNotificationItemsToList(activityCenterNotifications) self.activityNotificationsChanged() proc addActivityCenterNotification*(self:ChatsView, activityCenterNotifications: seq[ActivityCenterNotification]) = diff --git a/src/app/chat/views/activity_notification_list.nim b/src/app/chat/views/activity_notification_list.nim index 0819e10055..43843d720c 100644 --- a/src/app/chat/views/activity_notification_list.nim +++ b/src/app/chat/views/activity_notification_list.nim @@ -48,6 +48,15 @@ QtObject: read = unreadCount notify = unreadCountChanged + proc hasMoreToShowChanged*(self: ActivityNotificationList) {.signal.} + + proc hasMoreToShow*(self: ActivityNotificationList): bool {.slot.} = + self.status.chat.activityCenterCursor != "" + + QtProperty[bool] hasMoreToShow: + read = hasMoreToShow + notify = hasMoreToShowChanged + method rowCount*(self: ActivityNotificationList, index: QModelIndex = nil): int = self.activityCenterNotifications.len method data(self: ActivityNotificationList, index: QModelIndex, role: int): QVariant = @@ -97,6 +106,10 @@ QtObject: NotifRoles.Accepted.int: "accepted" }.toTable + proc loadMoreNotifications(self: ActivityNotificationList) {.slot.} = + self.status.chat.activityCenterNotifications(false) + self.hasMoreToShowChanged() + proc markAllActivityCenterNotificationsRead(self: ActivityNotificationList): string {.slot.} = let error = self.status.chat.markAllActivityCenterNotificationsRead() if (error != ""): @@ -135,15 +148,23 @@ QtObject: self.endResetModel() - self.nbUnreadNotifications = self.status.chat.unreadActivityCenterNotificationsCount() - self.unreadCountChanged() - - proc addActivityNotificationItemToList*(self: ActivityNotificationList, activityCenterNotification: ActivityCenterNotification) = + proc addActivityNotificationItemToList*(self: ActivityNotificationList, activityCenterNotification: ActivityCenterNotification, addToCount: bool = true) = self.beginInsertRows(newQModelIndex(), self.activityCenterNotifications.len, self.activityCenterNotifications.len) self.activityCenterNotifications.add(self.toActivityCenterNotificationViewItem(activityCenterNotification)) self.endInsertRows() - if (not activityCenterNotification.read): - self.nbUnreadNotifications = self.nbUnreadNotifications + 1 \ No newline at end of file + if (addToCount and not activityCenterNotification.read): + self.nbUnreadNotifications = self.nbUnreadNotifications + 1 + + proc addActivityNotificationItemsToList*(self: ActivityNotificationList, activityCenterNotifications: seq[ActivityCenterNotification]) = + if (self.activityCenterNotifications.len == 0): + self.setNewData(activityCenterNotifications) + else: + for activityCenterNotification in activityCenterNotifications: + self.addActivityNotificationItemToList(activityCenterNotification, false) + + self.nbUnreadNotifications = self.status.chat.unreadActivityCenterNotificationsCount() + self.unreadCountChanged() + self.hasMoreToShowChanged() diff --git a/src/status/chat.nim b/src/status/chat.nim index 02d7636bbc..cb168f7a6e 100644 --- a/src/status/chat.nim +++ b/src/status/chat.nim @@ -552,7 +552,6 @@ proc activityCenterNotifications*(self: ChatModel, initialLoad: bool = true) = self.events.emit("activityCenterNotificationsLoaded", ActivityCenterNotificationsArgs(activityCenterNotifications: activityCenterNotificationsTuple[1])) - proc activityCenterNotifications*(self: ChatModel, cursor: string = "", activityCenterNotifications: seq[ActivityCenterNotification]) = self.activityCenterCursor = cursor diff --git a/ui/app/AppLayouts/Chat/ChatColumn/ActivityCenter.qml b/ui/app/AppLayouts/Chat/ChatColumn/ActivityCenter.qml index 1414c41cec..a66a4e601b 100644 --- a/ui/app/AppLayouts/Chat/ChatColumn/ActivityCenter.qml +++ b/ui/app/AppLayouts/Chat/ChatColumn/ActivityCenter.qml @@ -212,15 +212,19 @@ Popup { } } - // StyledText { - // text: "Today" - // anchors.left: parent.left - // anchors.leftMargin: Style.current.padding - // font.pixelSize: 15 - // bottomPadding: 4 - // topPadding: Style.current.halfPadding - // color: Style.current.secondaryText - // } + Item { + visible: chatsModel.activityNotificationList.hasMoreToShow + width: parent.width + height: visible ? showMoreBtn.height + showMoreBtn.anchors.topMargin : 0 + StatusButton { + id: showMoreBtn + text: qsTr("Show more") + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + anchors.topMargin: Style.current.smallPadding + onClicked: chatsModel.activityNotificationList.loadMoreNotifications() + } + } } } }