parent
b257ccc87d
commit
354bd3e923
|
@ -45,7 +45,7 @@ proc newModule*(delegate: delegate_interface.AccessInterface, events: EventEmitt
|
||||||
belongsToCommunity: bool, isUsersListAvailable: bool, settingsService: settings_service.Service,
|
belongsToCommunity: bool, isUsersListAvailable: bool, settingsService: settings_service.Service,
|
||||||
nodeConfigurationService: node_configuration_service.Service, contactService: contact_service.Service, chatService: chat_service.Service,
|
nodeConfigurationService: node_configuration_service.Service, contactService: contact_service.Service, chatService: chat_service.Service,
|
||||||
communityService: community_service.Service, messageService: message_service.Service, gifService: gif_service.Service,
|
communityService: community_service.Service, messageService: message_service.Service, gifService: gif_service.Service,
|
||||||
mailserversService: mailservers_service.Service, communityUsersModule: users_module.AccessInterface):
|
mailserversService: mailservers_service.Service):
|
||||||
Module =
|
Module =
|
||||||
result = Module()
|
result = Module()
|
||||||
result.delegate = delegate
|
result.delegate = delegate
|
||||||
|
@ -59,11 +59,8 @@ proc newModule*(delegate: delegate_interface.AccessInterface, events: EventEmitt
|
||||||
chatService, communityService, gifService, messageService)
|
chatService, communityService, gifService, messageService)
|
||||||
result.messagesModule = messages_module.newModule(result, events, sectionId, chatId, belongsToCommunity,
|
result.messagesModule = messages_module.newModule(result, events, sectionId, chatId, belongsToCommunity,
|
||||||
contactService, communityService, chatService, messageService, mailserversService)
|
contactService, communityService, chatService, messageService, mailserversService)
|
||||||
result.usersModule =
|
result.usersModule = users_module.newModule(events, sectionId, chatId, belongsToCommunity,
|
||||||
if communityUsersModule == nil:
|
isUsersListAvailable, contactService, chat_service, communityService, messageService)
|
||||||
users_module.newModule( events, sectionId, chatId, belongsToCommunity,
|
|
||||||
isUsersListAvailable, contactService, chat_service, communityService, messageService)
|
|
||||||
else: communityUsersModule
|
|
||||||
|
|
||||||
method delete*(self: Module) =
|
method delete*(self: Module) =
|
||||||
self.controller.delete
|
self.controller.delete
|
||||||
|
|
|
@ -134,13 +134,13 @@ proc init*(self: Controller) =
|
||||||
if (self.belongsToCommunity):
|
if (self.belongsToCommunity):
|
||||||
self.handleCommunityOnlyConnections()
|
self.handleCommunityOnlyConnections()
|
||||||
|
|
||||||
|
proc belongsToCommunity*(self: Controller): bool =
|
||||||
|
self.belongsToCommunity
|
||||||
|
|
||||||
proc getChat*(self: Controller): ChatDto =
|
proc getChat*(self: Controller): ChatDto =
|
||||||
return self.chatService.getChatById(self.chatId)
|
return self.chatService.getChatById(self.chatId)
|
||||||
|
|
||||||
proc getChatMembers*(self: Controller): seq[ChatMember] =
|
proc getChatMembers*(self: Controller): seq[ChatMember] =
|
||||||
if self.belongsToCommunity:
|
|
||||||
return self.communityService.getCommunityById(self.sectionId).members
|
|
||||||
|
|
||||||
return self.chatService.getChatById(self.chatId).members
|
return self.chatService.getChatById(self.chatId).members
|
||||||
|
|
||||||
proc getContactNameAndImage*(self: Controller, contactId: string):
|
proc getContactNameAndImage*(self: Controller, contactId: string):
|
||||||
|
|
|
@ -98,7 +98,7 @@ proc addChatMember(self: Module, member: ChatMember) =
|
||||||
if member.id == "":
|
if member.id == "":
|
||||||
return
|
return
|
||||||
|
|
||||||
if not member.joined:
|
if not self.controller.belongsToCommunity() and not member.joined:
|
||||||
if self.view.model().isContactWithIdAdded(member.id):
|
if self.view.model().isContactWithIdAdded(member.id):
|
||||||
# Member is no longer joined
|
# Member is no longer joined
|
||||||
self.view.model().removeItemById(member.id)
|
self.view.model().removeItemById(member.id)
|
||||||
|
|
|
@ -340,9 +340,6 @@ method contactsStatusUpdated*(self: AccessInterface, statusUpdates: seq[StatusUp
|
||||||
method switchToChannel*(self: AccessInterface, channelName: string) {.base.} =
|
method switchToChannel*(self: AccessInterface, channelName: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method joinSpectatedCommunity*(self: AccessInterface) {.base.} =
|
|
||||||
raise newException(ValueError, "No implementation available")
|
|
||||||
|
|
||||||
method createOrEditCommunityTokenPermission*(self: AccessInterface, communityId: string, permissionId: string, permissionType: int, tokenCriteriaJson: string, channelIDs: seq[string], isPrivate: bool) {.base.} =
|
method createOrEditCommunityTokenPermission*(self: AccessInterface, communityId: string, permissionId: string, permissionType: int, tokenCriteriaJson: string, channelIDs: seq[string], isPrivate: bool) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,6 @@ type
|
||||||
chatContentModules: OrderedTable[string, chat_content_module.AccessInterface]
|
chatContentModules: OrderedTable[string, chat_content_module.AccessInterface]
|
||||||
moduleLoaded: bool
|
moduleLoaded: bool
|
||||||
chatsLoaded: bool
|
chatsLoaded: bool
|
||||||
usersModule: users_module.AccessInterface
|
|
||||||
|
|
||||||
# Forward declaration
|
# Forward declaration
|
||||||
proc buildChatSectionUI(self: Module,
|
proc buildChatSectionUI(self: Module,
|
||||||
|
@ -114,12 +113,6 @@ proc newModule*(
|
||||||
|
|
||||||
result.chatContentModules = initOrderedTable[string, chat_content_module.AccessInterface]()
|
result.chatContentModules = initOrderedTable[string, chat_content_module.AccessInterface]()
|
||||||
|
|
||||||
# Simple community channels uses comminity usersModule while chats uses their own usersModule
|
|
||||||
if isCommunity:
|
|
||||||
result.usersModule = users_module.newModule(
|
|
||||||
events, sectionId, chatId = "", belongsToCommunity = true, isUsersListAvailable = true,
|
|
||||||
contactService, chat_service, communityService, messageService)
|
|
||||||
|
|
||||||
method delete*(self: Module) =
|
method delete*(self: Module) =
|
||||||
self.controller.delete
|
self.controller.delete
|
||||||
self.view.delete
|
self.view.delete
|
||||||
|
@ -127,8 +120,6 @@ method delete*(self: Module) =
|
||||||
for cModule in self.chatContentModules.values:
|
for cModule in self.chatContentModules.values:
|
||||||
cModule.delete
|
cModule.delete
|
||||||
self.chatContentModules.clear
|
self.chatContentModules.clear
|
||||||
if self.usersModule != nil:
|
|
||||||
self.usersModule.delete
|
|
||||||
|
|
||||||
method isCommunity*(self: Module): bool =
|
method isCommunity*(self: Module): bool =
|
||||||
return self.controller.isCommunity()
|
return self.controller.isCommunity()
|
||||||
|
@ -153,7 +144,7 @@ proc addSubmodule(self: Module, chatId: string, belongToCommunity: bool, isUsers
|
||||||
mailserversService: mailservers_service.Service) =
|
mailserversService: mailservers_service.Service) =
|
||||||
self.chatContentModules[chatId] = chat_content_module.newModule(self, events, self.controller.getMySectionId(), chatId,
|
self.chatContentModules[chatId] = chat_content_module.newModule(self, events, self.controller.getMySectionId(), chatId,
|
||||||
belongToCommunity, isUsersListAvailable, settingsService, nodeConfigurationService, contactService, chatService, communityService,
|
belongToCommunity, isUsersListAvailable, settingsService, nodeConfigurationService, contactService, chatService, communityService,
|
||||||
messageService, gifService, mailserversService, self.usersModule)
|
messageService, gifService, mailserversService)
|
||||||
|
|
||||||
proc removeSubmodule(self: Module, chatId: string) =
|
proc removeSubmodule(self: Module, chatId: string) =
|
||||||
if(not self.chatContentModules.contains(chatId)):
|
if(not self.chatContentModules.contains(chatId)):
|
||||||
|
@ -352,7 +343,6 @@ method onChatsLoaded*(
|
||||||
# we do this only in case of chat section (not in case of communities)
|
# we do this only in case of chat section (not in case of communities)
|
||||||
self.initContactRequestsModel()
|
self.initContactRequestsModel()
|
||||||
else:
|
else:
|
||||||
self.usersModule.load()
|
|
||||||
let community = self.controller.getMyCommunity()
|
let community = self.controller.getMyCommunity()
|
||||||
self.view.setAmIMember(community.joined)
|
self.view.setAmIMember(community.joined)
|
||||||
self.initCommunityTokenPermissionsModel(channelGroup)
|
self.initCommunityTokenPermissionsModel(channelGroup)
|
||||||
|
@ -1279,10 +1269,6 @@ method contactsStatusUpdated*(self: Module, statusUpdates: seq[StatusUpdateDto])
|
||||||
let status = toOnlineStatus(s.statusType)
|
let status = toOnlineStatus(s.statusType)
|
||||||
self.view.chatsModel().updateItemOnlineStatusById(s.publicKey, status)
|
self.view.chatsModel().updateItemOnlineStatusById(s.publicKey, status)
|
||||||
|
|
||||||
method joinSpectatedCommunity*(self: Module) =
|
|
||||||
if self.usersModule != nil:
|
|
||||||
self.usersModule.updateMembersList()
|
|
||||||
|
|
||||||
method createOrEditCommunityTokenPermission*(self: Module, communityId: string, permissionId: string, permissionType: int, tokenCriteriaJson: string, channelIDs: seq[string], isPrivate: bool) =
|
method createOrEditCommunityTokenPermission*(self: Module, communityId: string, permissionId: string, permissionType: int, tokenCriteriaJson: string, channelIDs: seq[string], isPrivate: bool) =
|
||||||
|
|
||||||
var tokenPermission = CommunityTokenPermissionDto()
|
var tokenPermission = CommunityTokenPermissionDto()
|
||||||
|
|
|
@ -163,8 +163,9 @@ QtObject:
|
||||||
if (chatDto.active):
|
if (chatDto.active):
|
||||||
chats.add(chatDto)
|
chats.add(chatDto)
|
||||||
|
|
||||||
# Handling members update
|
# Handling members update for non-community chats
|
||||||
if self.chats.hasKey(chatDto.id) and self.chats[chatDto.id].members != chatDto.members:
|
let isCommunityChat = chatDto.chatType == ChatType.CommunityChat
|
||||||
|
if not isCommunityChat and self.chats.hasKey(chatDto.id) and self.chats[chatDto.id].members != chatDto.members:
|
||||||
self.events.emit(SIGNAL_CHAT_MEMBERS_CHANGED, ChatMembersChangedArgs(chatId: chatDto.id, members: chatDto.members))
|
self.events.emit(SIGNAL_CHAT_MEMBERS_CHANGED, ChatMembersChangedArgs(chatId: chatDto.id, members: chatDto.members))
|
||||||
self.updateOrAddChat(chatDto)
|
self.updateOrAddChat(chatDto)
|
||||||
|
|
||||||
|
@ -354,6 +355,15 @@ QtObject:
|
||||||
self.channelGroups[channelGroup.id] = newChannelGroup
|
self.channelGroups[channelGroup.id] = newChannelGroup
|
||||||
for chat in newChannelGroup.chats:
|
for chat in newChannelGroup.chats:
|
||||||
self.updateOrAddChat(chat)
|
self.updateOrAddChat(chat)
|
||||||
|
|
||||||
|
proc updateChannelMembers*(self: Service, channel: ChatDto) =
|
||||||
|
if not self.chats.hasKey(channel.id):
|
||||||
|
return
|
||||||
|
|
||||||
|
var chat = self.chats[channel.id]
|
||||||
|
chat.members = channel.members
|
||||||
|
self.updateOrAddChat(chat)
|
||||||
|
self.events.emit(SIGNAL_CHAT_MEMBERS_CHANGED, ChatMembersChangedArgs(chatId: chat.id, members: chat.members))
|
||||||
|
|
||||||
proc getChannelGroupById*(self: Service, channelGroupId: string): ChannelGroupDto =
|
proc getChannelGroupById*(self: Service, channelGroupId: string): ChannelGroupDto =
|
||||||
if not self.channelGroups.contains(channelGroupId):
|
if not self.channelGroups.contains(channelGroupId):
|
||||||
|
|
|
@ -362,6 +362,7 @@ QtObject:
|
||||||
chatDto.position = chat.position
|
chatDto.position = chat.position
|
||||||
chatDto.canPost = chat.canPost
|
chatDto.canPost = chat.canPost
|
||||||
chatDto.categoryId = chat.categoryId
|
chatDto.categoryId = chat.categoryId
|
||||||
|
chatDto.members = chat.members
|
||||||
|
|
||||||
proc findChatById(id: string, chats: seq[ChatDto]): ChatDto =
|
proc findChatById(id: string, chats: seq[ChatDto]): ChatDto =
|
||||||
for chat in chats:
|
for chat in chats:
|
||||||
|
@ -558,6 +559,10 @@ QtObject:
|
||||||
let data = CommunityChatArgs(chat: updatedChat)
|
let data = CommunityChatArgs(chat: updatedChat)
|
||||||
self.events.emit(SIGNAL_COMMUNITY_CHANNEL_EDITED, data)
|
self.events.emit(SIGNAL_COMMUNITY_CHANNEL_EDITED, data)
|
||||||
|
|
||||||
|
# Handle channel members update
|
||||||
|
if chat.members != prev_chat.members:
|
||||||
|
self.chatService.updateChannelMembers(chat)
|
||||||
|
|
||||||
# members list was changed
|
# members list was changed
|
||||||
if (community.isMember or community.tokenPermissions.len == 0) and community.members != prev_community.members:
|
if (community.isMember or community.tokenPermissions.len == 0) and community.members != prev_community.members:
|
||||||
self.events.emit(SIGNAL_COMMUNITY_MEMBERS_CHANGED,
|
self.events.emit(SIGNAL_COMMUNITY_MEMBERS_CHANGED,
|
||||||
|
|
|
@ -144,14 +144,7 @@ StatusSectionLayout {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
store: root.rootStore
|
store: root.rootStore
|
||||||
label: qsTr("Members")
|
label: qsTr("Members")
|
||||||
usersModel: {
|
usersModel: root.chatContentModule && root.chatContentModule.usersModule ? root.chatContentModule.usersModule.model : null
|
||||||
let chatContentModule = root.rootStore.currentChatContentModule()
|
|
||||||
if (!chatContentModule || !chatContentModule.usersModule) {
|
|
||||||
// New communities have no chats, so no chatContentModule
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
return chatContentModule.usersModule.model
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue