parent
2ef6e04b0a
commit
36ff742b52
|
@ -58,7 +58,12 @@ proc handleCommunityOnlyConnections(self: Controller) =
|
||||||
if (community.id != self.sectionId):
|
if (community.id != self.sectionId):
|
||||||
continue
|
continue
|
||||||
let membersPubKeys = community.members.map(x => x.id)
|
let membersPubKeys = community.members.map(x => x.id)
|
||||||
self.delegate.onChatMembersAdded(membersPubKeys)
|
self.delegate.onChatMembersAddedOrRemoved(membersPubKeys)
|
||||||
|
|
||||||
|
self.events.on(SIGNAL_COMMUNITY_MEMBER_REMOVED) do(e: Args):
|
||||||
|
let args = CommunityMemberArgs(e)
|
||||||
|
if (args.communityId == self.sectionId):
|
||||||
|
self.delegate.onChatMemberRemoved(args.pubKey)
|
||||||
|
|
||||||
proc init*(self: Controller) =
|
proc init*(self: Controller) =
|
||||||
# Events that are needed for all chats because of mentions
|
# Events that are needed for all chats because of mentions
|
||||||
|
@ -144,11 +149,6 @@ proc init*(self: Controller) =
|
||||||
if (self.belongsToCommunity):
|
if (self.belongsToCommunity):
|
||||||
self.handleCommunityOnlyConnections()
|
self.handleCommunityOnlyConnections()
|
||||||
|
|
||||||
self.events.on(SIGNAL_COMMUNITY_MEMBER_REMOVED) do(e: Args):
|
|
||||||
let args = CommunityMemberArgs(e)
|
|
||||||
if (args.communityId == self.sectionId):
|
|
||||||
self.delegate.onChatMemberRemoved(args.pubKey)
|
|
||||||
|
|
||||||
proc getChat*(self: Controller): ChatDto =
|
proc getChat*(self: Controller): ChatDto =
|
||||||
return self.chatService.getChatById(self.chatId)
|
return self.chatService.getChatById(self.chatId)
|
||||||
|
|
||||||
|
|
|
@ -37,13 +37,16 @@ method loggedInUserImageChanged*(self: AccessInterface) {.base.} =
|
||||||
method addChatMember*(self: AccessInterface, member: ChatMember) {.base.} =
|
method addChatMember*(self: AccessInterface, member: ChatMember) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method onChatMembersAddedOrRemoved*(self: AccessInterface, ids: seq[string]) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method onChatMembersAdded*(self: AccessInterface, ids: seq[string]) {.base.} =
|
method onChatMembersAdded*(self: AccessInterface, ids: seq[string]) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method onChatUpdated*(self: AccessInterface, chat: ChatDto) {.base.} =
|
method onChatMemberRemoved*(self: AccessInterface, ids: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method onChatMemberRemoved*(self: AccessInterface, ids: string) {.base.} =
|
method onChatUpdated*(self: AccessInterface, chat: ChatDto) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method onChatMemberUpdated*(self: AccessInterface, id: string, admin: bool, joined: bool) {.base.} =
|
method onChatMemberUpdated*(self: AccessInterface, id: string, admin: bool, joined: bool) {.base.} =
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import NimQml, strutils
|
import NimQml, strutils, sequtils, sugar
|
||||||
import io_interface
|
import io_interface
|
||||||
import ../io_interface as delegate_interface
|
import ../io_interface as delegate_interface
|
||||||
import view, controller
|
import view, controller
|
||||||
|
@ -176,6 +176,16 @@ method onChatUpdated*(self: Module, chat: ChatDto) =
|
||||||
method onChatMemberRemoved*(self: Module, id: string) =
|
method onChatMemberRemoved*(self: Module, id: string) =
|
||||||
self.view.model().removeItemById(id)
|
self.view.model().removeItemById(id)
|
||||||
|
|
||||||
|
method onChatMembersAddedOrRemoved*(self: Module, ids: seq[string]) =
|
||||||
|
let modelIDs = self.view.model().getItemIds()
|
||||||
|
let membersAdded = filter(ids, id => not modelIDs.contains(id))
|
||||||
|
let membersRemoved = filter(modelIDs, id => not ids.contains(id))
|
||||||
|
|
||||||
|
self.onChatMembersAdded(membersAdded)
|
||||||
|
for id in membersRemoved:
|
||||||
|
self.onChatMemberRemoved(id)
|
||||||
|
|
||||||
|
|
||||||
method onChatMemberUpdated*(self: Module, publicKey: string, admin: bool, joined: bool) =
|
method onChatMemberUpdated*(self: Module, publicKey: string, admin: bool, joined: bool) =
|
||||||
let contactDetails = self.controller.getContactDetails(publicKey)
|
let contactDetails = self.controller.getContactDetails(publicKey)
|
||||||
self.view.model().updateItem(
|
self.view.model().updateItem(
|
||||||
|
|
Loading…
Reference in New Issue