parent
414b39d7e0
commit
0b00a426ae
|
@ -516,7 +516,7 @@ QtObject:
|
||||||
self.messageList[msg.chatId].changeMessagePinned(msg.id, true, msg.pinnedBy)
|
self.messageList[msg.chatId].changeMessagePinned(msg.id, true, msg.pinnedBy)
|
||||||
|
|
||||||
proc pushActivityCenterNotifications*(self:ChatsView, activityCenterNotifications: seq[ActivityCenterNotification]) =
|
proc pushActivityCenterNotifications*(self:ChatsView, activityCenterNotifications: seq[ActivityCenterNotification]) =
|
||||||
self.activityNotificationList.setNewData(activityCenterNotifications)
|
self.activityNotificationList.addActivityNotificationItemsToList(activityCenterNotifications)
|
||||||
self.activityNotificationsChanged()
|
self.activityNotificationsChanged()
|
||||||
|
|
||||||
proc addActivityCenterNotification*(self:ChatsView, activityCenterNotifications: seq[ActivityCenterNotification]) =
|
proc addActivityCenterNotification*(self:ChatsView, activityCenterNotifications: seq[ActivityCenterNotification]) =
|
||||||
|
|
|
@ -48,6 +48,15 @@ QtObject:
|
||||||
read = unreadCount
|
read = unreadCount
|
||||||
notify = unreadCountChanged
|
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 rowCount*(self: ActivityNotificationList, index: QModelIndex = nil): int = self.activityCenterNotifications.len
|
||||||
|
|
||||||
method data(self: ActivityNotificationList, index: QModelIndex, role: int): QVariant =
|
method data(self: ActivityNotificationList, index: QModelIndex, role: int): QVariant =
|
||||||
|
@ -97,6 +106,10 @@ QtObject:
|
||||||
NotifRoles.Accepted.int: "accepted"
|
NotifRoles.Accepted.int: "accepted"
|
||||||
}.toTable
|
}.toTable
|
||||||
|
|
||||||
|
proc loadMoreNotifications(self: ActivityNotificationList) {.slot.} =
|
||||||
|
self.status.chat.activityCenterNotifications(false)
|
||||||
|
self.hasMoreToShowChanged()
|
||||||
|
|
||||||
proc markAllActivityCenterNotificationsRead(self: ActivityNotificationList): string {.slot.} =
|
proc markAllActivityCenterNotificationsRead(self: ActivityNotificationList): string {.slot.} =
|
||||||
let error = self.status.chat.markAllActivityCenterNotificationsRead()
|
let error = self.status.chat.markAllActivityCenterNotificationsRead()
|
||||||
if (error != ""):
|
if (error != ""):
|
||||||
|
@ -135,15 +148,23 @@ QtObject:
|
||||||
|
|
||||||
self.endResetModel()
|
self.endResetModel()
|
||||||
|
|
||||||
self.nbUnreadNotifications = self.status.chat.unreadActivityCenterNotificationsCount()
|
proc addActivityNotificationItemToList*(self: ActivityNotificationList, activityCenterNotification: ActivityCenterNotification, addToCount: bool = true) =
|
||||||
self.unreadCountChanged()
|
|
||||||
|
|
||||||
proc addActivityNotificationItemToList*(self: ActivityNotificationList, activityCenterNotification: ActivityCenterNotification) =
|
|
||||||
self.beginInsertRows(newQModelIndex(), self.activityCenterNotifications.len, self.activityCenterNotifications.len)
|
self.beginInsertRows(newQModelIndex(), self.activityCenterNotifications.len, self.activityCenterNotifications.len)
|
||||||
|
|
||||||
self.activityCenterNotifications.add(self.toActivityCenterNotificationViewItem(activityCenterNotification))
|
self.activityCenterNotifications.add(self.toActivityCenterNotificationViewItem(activityCenterNotification))
|
||||||
|
|
||||||
self.endInsertRows()
|
self.endInsertRows()
|
||||||
|
|
||||||
if (not activityCenterNotification.read):
|
if (addToCount and not activityCenterNotification.read):
|
||||||
self.nbUnreadNotifications = self.nbUnreadNotifications + 1
|
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]))
|
self.events.emit("activityCenterNotificationsLoaded", ActivityCenterNotificationsArgs(activityCenterNotifications: activityCenterNotificationsTuple[1]))
|
||||||
|
|
||||||
|
|
||||||
proc activityCenterNotifications*(self: ChatModel, cursor: string = "", activityCenterNotifications: seq[ActivityCenterNotification]) =
|
proc activityCenterNotifications*(self: ChatModel, cursor: string = "", activityCenterNotifications: seq[ActivityCenterNotification]) =
|
||||||
self.activityCenterCursor = cursor
|
self.activityCenterCursor = cursor
|
||||||
|
|
||||||
|
|
|
@ -212,15 +212,19 @@ Popup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// StyledText {
|
Item {
|
||||||
// text: "Today"
|
visible: chatsModel.activityNotificationList.hasMoreToShow
|
||||||
// anchors.left: parent.left
|
width: parent.width
|
||||||
// anchors.leftMargin: Style.current.padding
|
height: visible ? showMoreBtn.height + showMoreBtn.anchors.topMargin : 0
|
||||||
// font.pixelSize: 15
|
StatusButton {
|
||||||
// bottomPadding: 4
|
id: showMoreBtn
|
||||||
// topPadding: Style.current.halfPadding
|
text: qsTr("Show more")
|
||||||
// color: Style.current.secondaryText
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
// }
|
anchors.top: parent.top
|
||||||
|
anchors.topMargin: Style.current.smallPadding
|
||||||
|
onClicked: chatsModel.activityNotificationList.loadMoreNotifications()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue