switch deletedMessages from string array to object array

This commit is contained in:
Richard Ramos 2021-08-20 18:04:11 -04:00 committed by Iuri Matias
parent db3b7ecfd9
commit 6561e0ea26
6 changed files with 20 additions and 8 deletions

View File

@ -83,8 +83,8 @@ proc handleChatEvents(self: ChatController) =
self.view.addActivityCenterNotification(evArgs.activityCenterNotifications)
if (evArgs.deletedMessages.len > 0):
for messageId in evArgs.deletedMessages:
self.view.deleteMessage(messageId)
for m in evArgs.deletedMessages:
discard self.view.deleteMessage(m.chatId, m.messageId)
self.status.events.on("channelUpdate") do(e: Args):
var evArgs = ChatUpdateArgs(e)

View File

@ -31,7 +31,7 @@ type
communityMembershipRequests*: seq[CommunityMembershipRequest]
activityCenterNotifications*: seq[ActivityCenterNotification]
statusUpdates*: seq[StatusUpdate]
deletedMessages*: seq[string]
deletedMessages*: seq[RemovedMessage]
ChatIdArg* = ref object of Args
chatId*: string
@ -104,7 +104,7 @@ QtObject:
result.setup()
proc update*(self: ChatModel, chats: seq[Chat], messages: seq[Message], emojiReactions: seq[Reaction], communities: seq[Community], communityMembershipRequests: seq[CommunityMembershipRequest], pinnedMessages: seq[Message], activityCenterNotifications: seq[ActivityCenterNotification], statusUpdates: seq[StatusUpdate], deletedMessages: seq[string]) =
proc update*(self: ChatModel, chats: seq[Chat], messages: seq[Message], emojiReactions: seq[Reaction], communities: seq[Community], communityMembershipRequests: seq[CommunityMembershipRequest], pinnedMessages: seq[Message], activityCenterNotifications: seq[ActivityCenterNotification], statusUpdates: seq[StatusUpdate], deletedMessages: seq[RemovedMessage]) =
for chat in chats:
self.channels[chat.id] = chat

View File

@ -89,6 +89,10 @@ type Chat* = ref object
canPost*: bool
ensName*: string
type RemovedMessage* = object
chatId*: string
messageId*: string
type CommunityAccessLevel* = enum
unknown = 0
public = 1

View File

@ -29,6 +29,8 @@ proc toCommunityMembershipRequest*(jsonCommunityMembershipRequest: JsonNode): Co
proc toActivityCenterNotification*(jsonNotification: JsonNode): ActivityCenterNotification
proc toRemovedMessage*(jsonRemovedMessage: JsonNode): RemovedMessage
proc fromEvent*(event: JsonNode): Signal =
var signal:MessageSignal = MessageSignal()
signal.messages = @[]
@ -76,8 +78,8 @@ proc fromEvent*(event: JsonNode): Signal =
signal.membershipRequests.add(jsonCommunity.toCommunityMembershipRequest)
if event["event"]{"removedMessages"} != nil:
for messageId in event["event"]["removedMessages"]:
signal.deletedMessages.add(messageId.getStr)
for jsonRemovedMessage in event["event"]["removedMessages"]:
signal.deletedMessages.add(jsonRemovedMessage.toRemovedMessage)
if event["event"]{"activityCenterNotifications"} != nil:
for jsonNotification in event["event"]["activityCenterNotifications"]:
@ -283,6 +285,12 @@ proc toCommunityMembershipRequest*(jsonCommunityMembershipRequest: JsonNode): Co
our: jsonCommunityMembershipRequest{"our"}.getStr,
)
proc toRemovedMessage*(jsonRemovedMessage: JsonNode): RemovedMessage =
result = RemovedMessage(
chatId: jsonRemovedMessage{"chatId"}.getStr,
messageId: jsonRemovedMessage{"messageId"}.getStr,
)
proc toTextItem*(jsonText: JsonNode): TextItem =
result = TextItem(
literal: jsonText{"literal"}.getStr,

View File

@ -38,7 +38,7 @@ type MessageSignal* = ref object of Signal
membershipRequests*: seq[CommunityMembershipRequest]
activityCenterNotification*: seq[ActivityCenterNotification]
statusUpdates*: seq[StatusUpdate]
deletedMessages*: seq[string]
deletedMessages*: seq[RemovedMessage]
type CommunitySignal* = ref object of Signal
community*: Community

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 8f9c644daeaa057a1291f31c667e6a8ea2393aec
Subproject commit 20363e32ef96d4b5631ef4dd375bdb65252e6416