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