feat(ActivityCenter): allow users to mark notifications as unread
As raised in #3665, users aren't able to mark activity center notifications as unread. The APIs for that didn't exist yet so they have been added in: - status-go (https://github.com/status-im/status-go/pull/2383) - status-lib (https://github.com/status-im/status-lib/pull/53) respectively. Closes #3665
This commit is contained in:
parent
da28629ffc
commit
23b72a9e8d
|
@ -135,6 +135,28 @@ QtObject:
|
||||||
self.nbUnreadNotifications = 0
|
self.nbUnreadNotifications = 0
|
||||||
self.unreadCountChanged()
|
self.unreadCountChanged()
|
||||||
|
|
||||||
|
proc markActivityCenterNotificationUnread(self: ActivityNotificationList, notificationId: string,
|
||||||
|
communityId: string, channelId: string, nType: int): void {.slot.} =
|
||||||
|
let notificationType = ActivityCenterNotificationType(nType)
|
||||||
|
let markAsUnreadProps = MarkAsUnreadNotificationProperties(communityId: communityId,
|
||||||
|
channelId: channelId, notificationTypes: @[notificationType])
|
||||||
|
|
||||||
|
let error = self.status.chat.markActivityCenterNotificationUnread(notificationId, markAsUnreadProps)
|
||||||
|
if (error != ""):
|
||||||
|
return
|
||||||
|
|
||||||
|
self.nbUnreadNotifications = self.nbUnreadNotifications + 1
|
||||||
|
self.unreadCountChanged()
|
||||||
|
|
||||||
|
var i = 0
|
||||||
|
for acnViewItem in self.activityCenterNotifications:
|
||||||
|
if (acnViewItem.id == notificationId):
|
||||||
|
acnViewItem.read = false
|
||||||
|
let index = self.createIndex(i, 0, nil)
|
||||||
|
self.dataChanged(index, index, @[NotifRoles.Read.int])
|
||||||
|
break
|
||||||
|
i.inc
|
||||||
|
|
||||||
proc markActivityCenterNotificationRead(self: ActivityNotificationList, notificationId: string,
|
proc markActivityCenterNotificationRead(self: ActivityNotificationList, notificationId: string,
|
||||||
communityId: string, channelId: string, nType: int): void {.slot.} =
|
communityId: string, channelId: string, nType: int): void {.slot.} =
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,8 @@ import QtQuick 2.13
|
||||||
|
|
||||||
import utils 1.0
|
import utils 1.0
|
||||||
|
|
||||||
import StatusQ.Controls 0.1 as StatusQ
|
import StatusQ.Controls 0.1
|
||||||
|
|
||||||
import shared 1.0
|
|
||||||
import shared.popups 1.0
|
import shared.popups 1.0
|
||||||
|
|
||||||
import "../controls"
|
import "../controls"
|
||||||
|
@ -38,7 +37,7 @@ Item {
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: markReadBtnComponent
|
id: markReadBtnComponent
|
||||||
StatusQ.StatusFlatRoundButton {
|
StatusFlatRoundButton {
|
||||||
id: markReadBtn
|
id: markReadBtn
|
||||||
width: 32
|
width: 32
|
||||||
height: 32
|
height: 32
|
||||||
|
@ -47,11 +46,18 @@ Item {
|
||||||
icon.source: Style.svg("double-check")
|
icon.source: Style.svg("double-check")
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
//% "Mark as Read"
|
//% "Mark as Read"
|
||||||
tooltip.text: qsTrId("mark-as-read")
|
tooltip.text: !model.read ?
|
||||||
tooltip.orientation: StatusQ.StatusToolTip.Orientation.Left
|
qsTr("Mark as Read") :
|
||||||
|
qsTr("Mark as Unread")
|
||||||
|
tooltip.orientation: StatusToolTip.Orientation.Left
|
||||||
tooltip.x: -tooltip.width - Style.current.padding
|
tooltip.x: -tooltip.width - Style.current.padding
|
||||||
tooltip.y: markReadBtn.height / 2 - height / 2 + 4
|
tooltip.y: markReadBtn.height / 2 - height / 2 + 4
|
||||||
onClicked: root.store.chatsModelInst.activityNotificationList.markActivityCenterNotificationRead(model.id, model.message.communityId, model.message.chatId, model.notificationType)
|
onClicked: {
|
||||||
|
if (!model.read) {
|
||||||
|
return root.store.chatsModelInst.activityNotificationList.markActivityCenterNotificationRead(model.id, model.message.communityId, model.message.chatId, model.notificationType)
|
||||||
|
}
|
||||||
|
return root.store.chatsModelInst.activityNotificationList.markActivityCenterNotificationUnread(model.id, model.message.communityId, model.message.chatId, model.notificationType)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3348389ab7d5a80ee0b90287df2d9321b7620227
|
Subproject commit ffe6d5e0f0fbc699c931bdfbc72ddc42d8201251
|
Loading…
Reference in New Issue