parent
1f85ec1bd6
commit
c102d2de07
|
@ -80,7 +80,7 @@ method unreadActivityCenterNotificationsCountChanged*(self: Module) =
|
||||||
method hasUnseenActivityCenterNotificationsChanged*(self: Module) =
|
method hasUnseenActivityCenterNotificationsChanged*(self: Module) =
|
||||||
self.view.hasUnseenActivityCenterNotificationsChanged()
|
self.view.hasUnseenActivityCenterNotificationsChanged()
|
||||||
|
|
||||||
proc createMessageItemFromDto(self: Module, message: MessageDto, communityId: string): MessageItem =
|
proc createMessageItemFromDto(self: Module, message: MessageDto, communityId: string, albumMessages: seq[MessageDto]): MessageItem =
|
||||||
let contactDetails = self.controller.getContactDetails(message.`from`)
|
let contactDetails = self.controller.getContactDetails(message.`from`)
|
||||||
let communityChats = self.controller.getCommunityById(communityId).chats
|
let communityChats = self.controller.getCommunityById(communityId).chats
|
||||||
|
|
||||||
|
@ -91,6 +91,13 @@ proc createMessageItemFromDto(self: Module, message: MessageDto, communityId: st
|
||||||
else:
|
else:
|
||||||
quotedMessageAuthorDetails = self.controller.getContactDetails(message.quotedMessage.`from`)
|
quotedMessageAuthorDetails = self.controller.getContactDetails(message.quotedMessage.`from`)
|
||||||
|
|
||||||
|
var imagesAlbum: seq[string]
|
||||||
|
var albumMessageIds: seq[string]
|
||||||
|
if message.albumId != "":
|
||||||
|
for msg in albumMessages:
|
||||||
|
imagesAlbum.add(msg.image)
|
||||||
|
albumMessageIds.add(msg.id)
|
||||||
|
|
||||||
return msg_item_qobj.newMessageItem(msg_item.initItem(
|
return msg_item_qobj.newMessageItem(msg_item.initItem(
|
||||||
message.id,
|
message.id,
|
||||||
communityId, # we don't received community id via `activityCenterNotifications` api call
|
communityId, # we don't received community id via `activityCenterNotifications` api call
|
||||||
|
@ -133,8 +140,8 @@ proc createMessageItemFromDto(self: Module, message: MessageDto, communityId: st
|
||||||
message.quotedMessage.discordMessage,
|
message.quotedMessage.discordMessage,
|
||||||
quotedMessageAuthorDetails,
|
quotedMessageAuthorDetails,
|
||||||
message.albumId,
|
message.albumId,
|
||||||
if (len(message.albumId) == 0): @[] else: @[message.image],
|
imagesAlbum,
|
||||||
if (len(message.albumId) == 0): @[] else: @[message.id],
|
albumMessageIds,
|
||||||
message.albumImagesCount,
|
message.albumImagesCount,
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -155,13 +162,13 @@ method convertToItems*(
|
||||||
if (notification.message.id != ""):
|
if (notification.message.id != ""):
|
||||||
let communityId = sectionId
|
let communityId = sectionId
|
||||||
# If there is a message in the Notification, transfer it to a MessageItem (QObject)
|
# If there is a message in the Notification, transfer it to a MessageItem (QObject)
|
||||||
messageItem = self.createMessageItemFromDto(notification.message, communityId)
|
messageItem = self.createMessageItemFromDto(notification.message, communityId, notification.albumMessages)
|
||||||
|
|
||||||
if (notification.notificationType == ActivityCenterNotificationType.Reply and notification.message.responseTo != ""):
|
if (notification.notificationType == ActivityCenterNotificationType.Reply and notification.message.responseTo != ""):
|
||||||
repliedMessageItem = self.createMessageItemFromDto(notification.replyMessage, communityId)
|
repliedMessageItem = self.createMessageItemFromDto(notification.replyMessage, communityId, @[])
|
||||||
|
|
||||||
if (notification.notificationType == ActivityCenterNotificationType.ContactVerification):
|
if (notification.notificationType == ActivityCenterNotificationType.ContactVerification):
|
||||||
repliedMessageItem = self.createMessageItemFromDto(notification.replyMessage, communityId)
|
repliedMessageItem = self.createMessageItemFromDto(notification.replyMessage, communityId, @[])
|
||||||
|
|
||||||
return notification_item.initItem(
|
return notification_item.initItem(
|
||||||
notification.id,
|
notification.id,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import NimQml, std/wrapnils
|
import NimQml, std/wrapnils, strutils, strformat, sugar
|
||||||
import ./message_item
|
import ./message_item
|
||||||
|
|
||||||
QtObject:
|
QtObject:
|
||||||
|
@ -185,3 +185,15 @@ QtObject:
|
||||||
proc reactionsModel*(self: MessageItem): QVariant {.slot.} = result = newQVariant(?.self.messageItem.reactionsModel)
|
proc reactionsModel*(self: MessageItem): QVariant {.slot.} = result = newQVariant(?.self.messageItem.reactionsModel)
|
||||||
QtProperty[QVariant] reactionsModel:
|
QtProperty[QVariant] reactionsModel:
|
||||||
read = reactionsModel
|
read = reactionsModel
|
||||||
|
|
||||||
|
proc albumId*(self: MessageItem): string {.slot.} = result = ?.self.messageItem.albumId
|
||||||
|
QtProperty[string] albumId:
|
||||||
|
read = albumId
|
||||||
|
|
||||||
|
proc albumMessageImages*(self: MessageItem): string {.slot.} = result = ?.self.messageItem.albumMessageImages.join(" ")
|
||||||
|
QtProperty[string] albumMessageImages:
|
||||||
|
read = albumMessageImages
|
||||||
|
|
||||||
|
proc albumImagesCount*(self: MessageItem): int {.slot.} = result = ?.self.messageItem.albumImagesCount
|
||||||
|
QtProperty[int] albumImagesCount:
|
||||||
|
read = albumImagesCount
|
|
@ -57,6 +57,7 @@ type ActivityCenterNotificationDto* = ref object of RootObj
|
||||||
notificationType*: ActivityCenterNotificationType
|
notificationType*: ActivityCenterNotificationType
|
||||||
message*: MessageDto
|
message*: MessageDto
|
||||||
replyMessage*: MessageDto
|
replyMessage*: MessageDto
|
||||||
|
albumMessages*: seq[MessageDto]
|
||||||
timestamp*: int64
|
timestamp*: int64
|
||||||
read*: bool
|
read*: bool
|
||||||
dismissed*: bool
|
dismissed*: bool
|
||||||
|
@ -117,13 +118,18 @@ proc toActivityCenterNotificationDto*(jsonObj: JsonNode): ActivityCenterNotifica
|
||||||
discard jsonObj.getProp("accepted", result.accepted)
|
discard jsonObj.getProp("accepted", result.accepted)
|
||||||
|
|
||||||
if jsonObj.contains("message") and jsonObj{"message"}.kind != JNull:
|
if jsonObj.contains("message") and jsonObj{"message"}.kind != JNull:
|
||||||
result.message = jsonObj{"message"}.toMessageDto()
|
result.message = jsonObj["message"].toMessageDto()
|
||||||
elif result.notificationType == ActivityCenterNotificationType.NewOneToOne and
|
elif result.notificationType == ActivityCenterNotificationType.NewOneToOne and
|
||||||
jsonObj.contains("lastMessage") and jsonObj{"lastMessage"}.kind != JNull:
|
jsonObj.contains("lastMessage") and jsonObj{"lastMessage"}.kind != JNull:
|
||||||
result.message = jsonObj{"lastMessage"}.toMessageDto()
|
result.message = jsonObj["lastMessage"].toMessageDto()
|
||||||
|
|
||||||
if jsonObj.contains("replyMessage") and jsonObj{"replyMessage"}.kind != JNull:
|
if jsonObj.contains("replyMessage") and jsonObj{"replyMessage"}.kind != JNull:
|
||||||
result.replyMessage = jsonObj{"replyMessage"}.toMessageDto()
|
result.replyMessage = jsonObj["replyMessage"].toMessageDto()
|
||||||
|
|
||||||
|
if jsonObj.contains("albumMessages") and jsonObj{"albumMessages"}.kind != JNull:
|
||||||
|
let jsonAlbum = jsonObj["albumMessages"]
|
||||||
|
for msg in jsonAlbum:
|
||||||
|
result.albumMessages.add(toMessageDto(msg))
|
||||||
|
|
||||||
proc parseActivityCenterNotifications*(rpcResult: JsonNode): (string, seq[ActivityCenterNotificationDto]) =
|
proc parseActivityCenterNotifications*(rpcResult: JsonNode): (string, seq[ActivityCenterNotificationDto]) =
|
||||||
var notifs: seq[ActivityCenterNotificationDto] = @[]
|
var notifs: seq[ActivityCenterNotificationDto] = @[]
|
||||||
|
|
|
@ -40,6 +40,10 @@ ActivityNotificationBase {
|
||||||
colorId: Utils.colorIdForPubkey(contactId)
|
colorId: Utils.colorIdForPubkey(contactId)
|
||||||
colorHash: Utils.getColorHashAsJson(contactId, sender.isEnsVerified)
|
colorHash: Utils.getColorHashAsJson(contactId, sender.isEnsVerified)
|
||||||
}
|
}
|
||||||
|
contentType: notification && notification.message ? notification.message.contentType : StatusMessage.ContentType.Unknown
|
||||||
|
album: notification && notification.message ? notification.message.albumMessageImages.split(" ") : []
|
||||||
|
albumCount: notification && notification.message ? notification.message.albumImagesCount : 0
|
||||||
|
messageContent: notification && notification.message ? notification.message.messageImage : ""
|
||||||
}
|
}
|
||||||
|
|
||||||
property Component messageSubheaderComponent: null
|
property Component messageSubheaderComponent: null
|
||||||
|
|
|
@ -5,6 +5,7 @@ import StatusQ.Core 0.1
|
||||||
import StatusQ.Core.Utils 0.1 as CoreUtils
|
import StatusQ.Core.Utils 0.1 as CoreUtils
|
||||||
import StatusQ.Core.Theme 0.1
|
import StatusQ.Core.Theme 0.1
|
||||||
import StatusQ.Components 0.1
|
import StatusQ.Components 0.1
|
||||||
|
import StatusQ.Components.private 0.1
|
||||||
|
|
||||||
import shared 1.0
|
import shared 1.0
|
||||||
import utils 1.0
|
import utils 1.0
|
||||||
|
@ -89,5 +90,19 @@ RowLayout {
|
||||||
Layout.fillWidth: !!root.messageBadgeComponent
|
Layout.fillWidth: !!root.messageBadgeComponent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loader {
|
||||||
|
active: root.messageDetails.contentType === Constants.messageContentType.imageType
|
||||||
|
visible: active
|
||||||
|
Layout.fillWidth: true
|
||||||
|
sourceComponent: StatusMessageImageAlbum {
|
||||||
|
width: parent.width
|
||||||
|
album: root.messageDetails.albumCount > 0 ? root.messageDetails.album : [root.messageDetails.messageContent]
|
||||||
|
albumCount: root.messageDetails.albumCount || 1
|
||||||
|
imageWidth: 56
|
||||||
|
loadingComponentHeight: 56
|
||||||
|
shapeType: StatusImageMessage.ShapeType.ROUNDED
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit ad971278d948fbe80050cc56441b6470ca905326
|
Subproject commit d3c4ba315a90875ead7a68b238549a4c0163fc80
|
Loading…
Reference in New Issue