parent
80a3c932ce
commit
5f7e277065
|
@ -1,4 +1,4 @@
|
|||
import NimQml, Tables, chronicles
|
||||
import NimQml, Tables, chronicles, json, sequtils, strformat
|
||||
import ../../../status/chat/chat
|
||||
import ../../../status/status
|
||||
import ../../../status/accounts
|
||||
|
@ -125,6 +125,30 @@ QtObject:
|
|||
let bottomRight = self.createIndex(self.activityCenterNotifications.len - 1, 0, nil)
|
||||
self.dataChanged(topLeft, bottomRight, @[NotifRoles.Read.int])
|
||||
|
||||
proc markActivityCenterNotificationsRead(self: ActivityNotificationList, idsJson: string): string {.slot.} =
|
||||
let ids = map(parseJson(idsJson).getElems(), proc(x:JsonNode):string = x.getStr())
|
||||
|
||||
let error = self.status.chat.markActivityCenterNotificationsRead(ids)
|
||||
if (error != ""):
|
||||
return error
|
||||
|
||||
self.nbUnreadNotifications = self.nbUnreadNotifications - ids.len
|
||||
if (self.nbUnreadNotifications < 0):
|
||||
self.nbUnreadNotifications = 0
|
||||
self.unreadCountChanged()
|
||||
|
||||
var i = 0
|
||||
for activityCenterNotification in self.activityCenterNotifications:
|
||||
for id in ids:
|
||||
if (activityCenterNotification.id == id):
|
||||
activityCenterNotification.read = true
|
||||
let topLeft = self.createIndex(i, 0, nil)
|
||||
let bottomRight = self.createIndex(i, 0, nil)
|
||||
self.dataChanged(topLeft, bottomRight, @[NotifRoles.Read.int])
|
||||
i = i + 1
|
||||
|
||||
proc markActivityCenterNotificationRead(self: ActivityNotificationList, id: string): string {.slot.} =
|
||||
self.markActivityCenterNotificationsRead(fmt"[""{id}""]")
|
||||
|
||||
proc toActivityCenterNotificationViewItem*(self: ActivityNotificationList, activityCenterNotification: ActivityCenterNotification): ActivityCenterNotificationViewItem =
|
||||
ActivityCenterNotificationViewItem(
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import NimQml, json, sequtils, chronicles, strutils, strformat, json
|
||||
import NimQml, json, sequtils, chronicles, strutils, strformat
|
||||
import ../../../status/status
|
||||
import ../../../status/chat/chat
|
||||
import ./community_list
|
||||
|
|
|
@ -564,6 +564,12 @@ proc markAllActivityCenterNotificationsRead*(self: ChatModel): string =
|
|||
error "Error marking all as read", msg = e.msg
|
||||
result = e.msg
|
||||
|
||||
proc markActivityCenterNotificationsRead*(self: ChatModel, ids: seq[string]): string =
|
||||
try:
|
||||
status_chat.markActivityCenterNotificationsRead(ids)
|
||||
except Exception as e:
|
||||
error "Error marking as read", msg = e.msg
|
||||
result = e.msg
|
||||
|
||||
proc unreadActivityCenterNotificationsCount*(self: ChatModel): int =
|
||||
status_chat.unreadActivityCenterNotificationsCount()
|
||||
|
|
|
@ -591,6 +591,9 @@ proc activityCenterNotification*(cursor: string = ""): (string, seq[ActivityCent
|
|||
proc markAllActivityCenterNotificationsRead*() =
|
||||
discard callPrivateRPC("markAllActivityCenterNotificationsRead".prefix, %*[])
|
||||
|
||||
proc markActivityCenterNotificationsRead*(ids: seq[string]) =
|
||||
let res = callPrivateRPC("markActivityCenterNotificationsRead".prefix, %*[ids])
|
||||
|
||||
proc unreadActivityCenterNotificationsCount*(): int =
|
||||
let rpcResult = callPrivateRPC("unreadActivityCenterNotificationsCount".prefix, %*[]).parseJson
|
||||
|
||||
|
|
|
@ -176,29 +176,28 @@ Popup {
|
|||
prevMsgTimestamp: notificationDelegate.idx === 0 ? "" : chatsModel.activityNotificationList.getNotificationData(prevMessageIndex, "timestamp")
|
||||
}
|
||||
|
||||
// TODO add this back when single MarkAsRead is available
|
||||
// StatusIconButton {
|
||||
// id: markReadBtn
|
||||
// icon.name: "double-check"
|
||||
// iconColor: Style.current.primary
|
||||
// icon.width: 24
|
||||
// icon.height: 24
|
||||
// width: 32
|
||||
// height: 32
|
||||
// onClicked: console.log('TODO mark read')
|
||||
// anchors.right: parent.right
|
||||
// anchors.rightMargin: 12
|
||||
// anchors.verticalCenter: notificationMessage.verticalCenter
|
||||
// z: 52
|
||||
StatusIconButton {
|
||||
id: markReadBtn
|
||||
icon.name: "double-check"
|
||||
iconColor: Style.current.primary
|
||||
icon.width: 24
|
||||
icon.height: 24
|
||||
width: 32
|
||||
height: 32
|
||||
onClicked: chatsModel.activityNotificationList.markActivityCenterNotificationRead(model.id)
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 12
|
||||
anchors.verticalCenter: notificationMessage.verticalCenter
|
||||
z: 52
|
||||
|
||||
// StatusToolTip {
|
||||
// visible: markReadBtn.hovered
|
||||
// text: qsTr("Mark as Read")
|
||||
// orientation: "left"
|
||||
// x: - width - Style.current.padding
|
||||
// y: markReadBtn.height / 2 - height / 2 + 4
|
||||
// }
|
||||
// }
|
||||
StatusToolTip {
|
||||
visible: markReadBtn.hovered
|
||||
text: qsTr("Mark as Read")
|
||||
orientation: "left"
|
||||
x: - width - Style.current.padding
|
||||
y: markReadBtn.height / 2 - height / 2 + 4
|
||||
}
|
||||
}
|
||||
|
||||
ActivityChannelBadge {
|
||||
name: model.name
|
||||
|
|
Loading…
Reference in New Issue