switch deletedMessages from string array to object array
This commit is contained in:
parent
db3b7ecfd9
commit
6561e0ea26
|
@ -83,8 +83,8 @@ proc handleChatEvents(self: ChatController) =
|
||||||
self.view.addActivityCenterNotification(evArgs.activityCenterNotifications)
|
self.view.addActivityCenterNotification(evArgs.activityCenterNotifications)
|
||||||
|
|
||||||
if (evArgs.deletedMessages.len > 0):
|
if (evArgs.deletedMessages.len > 0):
|
||||||
for messageId in evArgs.deletedMessages:
|
for m in evArgs.deletedMessages:
|
||||||
self.view.deleteMessage(messageId)
|
discard self.view.deleteMessage(m.chatId, m.messageId)
|
||||||
|
|
||||||
self.status.events.on("channelUpdate") do(e: Args):
|
self.status.events.on("channelUpdate") do(e: Args):
|
||||||
var evArgs = ChatUpdateArgs(e)
|
var evArgs = ChatUpdateArgs(e)
|
||||||
|
|
|
@ -31,7 +31,7 @@ type
|
||||||
communityMembershipRequests*: seq[CommunityMembershipRequest]
|
communityMembershipRequests*: seq[CommunityMembershipRequest]
|
||||||
activityCenterNotifications*: seq[ActivityCenterNotification]
|
activityCenterNotifications*: seq[ActivityCenterNotification]
|
||||||
statusUpdates*: seq[StatusUpdate]
|
statusUpdates*: seq[StatusUpdate]
|
||||||
deletedMessages*: seq[string]
|
deletedMessages*: seq[RemovedMessage]
|
||||||
|
|
||||||
ChatIdArg* = ref object of Args
|
ChatIdArg* = ref object of Args
|
||||||
chatId*: string
|
chatId*: string
|
||||||
|
@ -104,7 +104,7 @@ QtObject:
|
||||||
|
|
||||||
result.setup()
|
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:
|
for chat in chats:
|
||||||
self.channels[chat.id] = chat
|
self.channels[chat.id] = chat
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,10 @@ type Chat* = ref object
|
||||||
canPost*: bool
|
canPost*: bool
|
||||||
ensName*: string
|
ensName*: string
|
||||||
|
|
||||||
|
type RemovedMessage* = object
|
||||||
|
chatId*: string
|
||||||
|
messageId*: string
|
||||||
|
|
||||||
type CommunityAccessLevel* = enum
|
type CommunityAccessLevel* = enum
|
||||||
unknown = 0
|
unknown = 0
|
||||||
public = 1
|
public = 1
|
||||||
|
|
|
@ -29,6 +29,8 @@ proc toCommunityMembershipRequest*(jsonCommunityMembershipRequest: JsonNode): Co
|
||||||
|
|
||||||
proc toActivityCenterNotification*(jsonNotification: JsonNode): ActivityCenterNotification
|
proc toActivityCenterNotification*(jsonNotification: JsonNode): ActivityCenterNotification
|
||||||
|
|
||||||
|
proc toRemovedMessage*(jsonRemovedMessage: JsonNode): RemovedMessage
|
||||||
|
|
||||||
proc fromEvent*(event: JsonNode): Signal =
|
proc fromEvent*(event: JsonNode): Signal =
|
||||||
var signal:MessageSignal = MessageSignal()
|
var signal:MessageSignal = MessageSignal()
|
||||||
signal.messages = @[]
|
signal.messages = @[]
|
||||||
|
@ -76,8 +78,8 @@ proc fromEvent*(event: JsonNode): Signal =
|
||||||
signal.membershipRequests.add(jsonCommunity.toCommunityMembershipRequest)
|
signal.membershipRequests.add(jsonCommunity.toCommunityMembershipRequest)
|
||||||
|
|
||||||
if event["event"]{"removedMessages"} != nil:
|
if event["event"]{"removedMessages"} != nil:
|
||||||
for messageId in event["event"]["removedMessages"]:
|
for jsonRemovedMessage in event["event"]["removedMessages"]:
|
||||||
signal.deletedMessages.add(messageId.getStr)
|
signal.deletedMessages.add(jsonRemovedMessage.toRemovedMessage)
|
||||||
|
|
||||||
if event["event"]{"activityCenterNotifications"} != nil:
|
if event["event"]{"activityCenterNotifications"} != nil:
|
||||||
for jsonNotification in event["event"]["activityCenterNotifications"]:
|
for jsonNotification in event["event"]["activityCenterNotifications"]:
|
||||||
|
@ -283,6 +285,12 @@ proc toCommunityMembershipRequest*(jsonCommunityMembershipRequest: JsonNode): Co
|
||||||
our: jsonCommunityMembershipRequest{"our"}.getStr,
|
our: jsonCommunityMembershipRequest{"our"}.getStr,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
proc toRemovedMessage*(jsonRemovedMessage: JsonNode): RemovedMessage =
|
||||||
|
result = RemovedMessage(
|
||||||
|
chatId: jsonRemovedMessage{"chatId"}.getStr,
|
||||||
|
messageId: jsonRemovedMessage{"messageId"}.getStr,
|
||||||
|
)
|
||||||
|
|
||||||
proc toTextItem*(jsonText: JsonNode): TextItem =
|
proc toTextItem*(jsonText: JsonNode): TextItem =
|
||||||
result = TextItem(
|
result = TextItem(
|
||||||
literal: jsonText{"literal"}.getStr,
|
literal: jsonText{"literal"}.getStr,
|
||||||
|
|
|
@ -38,7 +38,7 @@ type MessageSignal* = ref object of Signal
|
||||||
membershipRequests*: seq[CommunityMembershipRequest]
|
membershipRequests*: seq[CommunityMembershipRequest]
|
||||||
activityCenterNotification*: seq[ActivityCenterNotification]
|
activityCenterNotification*: seq[ActivityCenterNotification]
|
||||||
statusUpdates*: seq[StatusUpdate]
|
statusUpdates*: seq[StatusUpdate]
|
||||||
deletedMessages*: seq[string]
|
deletedMessages*: seq[RemovedMessage]
|
||||||
|
|
||||||
type CommunitySignal* = ref object of Signal
|
type CommunitySignal* = ref object of Signal
|
||||||
community*: Community
|
community*: Community
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8f9c644daeaa057a1291f31c667e6a8ea2393aec
|
Subproject commit 20363e32ef96d4b5631ef4dd375bdb65252e6416
|
Loading…
Reference in New Issue