parent
414b39d7e0
commit
0b00a426ae
|
@ -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]) =
|
||||
|
|
|
@ -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
|
||||
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()
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue