fix(@desktop/community): do not create a separate community module after we join opened spectated community
This commit is contained in:
parent
b7c4c7b582
commit
c2c9ede0f3
|
@ -57,3 +57,6 @@ method addGroupMembers*(self: AccessInterface, pubKeys: seq[string]) {.base.} =
|
||||||
|
|
||||||
method removeGroupMembers*(self: AccessInterface, pubKeys: seq[string]) {.base.} =
|
method removeGroupMembers*(self: AccessInterface, pubKeys: seq[string]) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method updateMembersList*(self: AccessInterface) =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
|
@ -53,10 +53,7 @@ method isLoaded*(self: Module): bool =
|
||||||
return self.moduleLoaded
|
return self.moduleLoaded
|
||||||
|
|
||||||
method viewDidLoad*(self: Module) =
|
method viewDidLoad*(self: Module) =
|
||||||
let members = self.controller.getChatMembers()
|
self.updateMembersList()
|
||||||
for member in members:
|
|
||||||
self.addChatMember(member)
|
|
||||||
|
|
||||||
self.moduleLoaded = true
|
self.moduleLoaded = true
|
||||||
|
|
||||||
method getModuleAsVariant*(self: Module): QVariant =
|
method getModuleAsVariant*(self: Module): QVariant =
|
||||||
|
@ -176,3 +173,8 @@ method addGroupMembers*(self: Module, pubKeys: seq[string]) =
|
||||||
|
|
||||||
method removeGroupMembers*(self: Module, pubKeys: seq[string]) =
|
method removeGroupMembers*(self: Module, pubKeys: seq[string]) =
|
||||||
self.controller.removeGroupMembers(pubKeys)
|
self.controller.removeGroupMembers(pubKeys)
|
||||||
|
|
||||||
|
method updateMembersList*(self: Module) =
|
||||||
|
let members = self.controller.getChatMembers()
|
||||||
|
for member in members:
|
||||||
|
self.addChatMember(member)
|
|
@ -325,3 +325,6 @@ method contactsStatusUpdated*(self: AccessInterface, statusUpdates: seq[StatusUp
|
||||||
|
|
||||||
method switchToChannel*(self: AccessInterface, channelName: string) =
|
method switchToChannel*(self: AccessInterface, channelName: string) =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method joinSpectatedCommunity*(self: AccessInterface) =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
|
@ -1017,3 +1017,7 @@ method contactsStatusUpdated*(self: Module, statusUpdates: seq[StatusUpdateDto])
|
||||||
for s in statusUpdates:
|
for s in statusUpdates:
|
||||||
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()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import NimQml, tables, json, sugar, sequtils, strformat, marshal, times
|
import NimQml, tables, json, sugar, sequtils, strformat, marshal, times, chronicles
|
||||||
|
|
||||||
import io_interface, view, controller, chat_search_item, chat_search_model
|
import io_interface, view, controller, chat_search_item, chat_search_model
|
||||||
import ephemeral_notification_item, ephemeral_notification_model
|
import ephemeral_notification_item, ephemeral_notification_model
|
||||||
|
@ -709,6 +709,24 @@ method communityJoined*[T](
|
||||||
var firstCommunityJoined = false
|
var firstCommunityJoined = false
|
||||||
if (self.channelGroupModules.len == 1): # First one is personal chat section
|
if (self.channelGroupModules.len == 1): # First one is personal chat section
|
||||||
firstCommunityJoined = true
|
firstCommunityJoined = true
|
||||||
|
|
||||||
|
if(community.permissions.access == COMMUNITY_PERMISSION_ACCESS_ON_REQUEST and
|
||||||
|
community.requestedToJoinAt > 0 and
|
||||||
|
community.joined):
|
||||||
|
singletonInstance.globalEvents.myRequestToJoinCommunityAcccepted("Community Request Accepted",
|
||||||
|
fmt "Your request to join community {community.name} is accepted", community.id)
|
||||||
|
self.displayEphemeralNotification(fmt "{community.name} membership approved ", "", conf.COMMUNITIESPORTAL_SECTION_ICON, false, EphemeralNotificationType.Success.int, "")
|
||||||
|
|
||||||
|
# if we are joining spectated community
|
||||||
|
if self.channelGroupModules.hasKey(community.id):
|
||||||
|
let communityModule = self.channelGroupModules[community.id]
|
||||||
|
# Must never happen
|
||||||
|
if not communityModule.isLoaded():
|
||||||
|
error "Community module was not loaded in spectated mode", communityId=community.id
|
||||||
|
|
||||||
|
communityModule.joinSpectatedCommunity()
|
||||||
|
return
|
||||||
|
|
||||||
self.channelGroupModules[community.id] = chat_section_module.newModule(
|
self.channelGroupModules[community.id] = chat_section_module.newModule(
|
||||||
self,
|
self,
|
||||||
events,
|
events,
|
||||||
|
@ -735,13 +753,6 @@ method communityJoined*[T](
|
||||||
else:
|
else:
|
||||||
self.view.model().addItem(communitySectionItem)
|
self.view.model().addItem(communitySectionItem)
|
||||||
|
|
||||||
if(community.permissions.access == COMMUNITY_PERMISSION_ACCESS_ON_REQUEST and
|
|
||||||
community.requestedToJoinAt > 0 and
|
|
||||||
community.joined):
|
|
||||||
singletonInstance.globalEvents.myRequestToJoinCommunityAcccepted("Community Request Accepted",
|
|
||||||
fmt "Your request to join community {community.name} is accepted", community.id)
|
|
||||||
self.displayEphemeralNotification(fmt "{community.name} membership approved ", "", conf.COMMUNITIESPORTAL_SECTION_ICON, false, EphemeralNotificationType.Success.int, "")
|
|
||||||
|
|
||||||
if setActive:
|
if setActive:
|
||||||
self.setActiveSection(communitySectionItem)
|
self.setActiveSection(communitySectionItem)
|
||||||
if(channelGroup.chats.len > 0):
|
if(channelGroup.chats.len > 0):
|
||||||
|
|
|
@ -70,7 +70,6 @@ type
|
||||||
CommunityMembersArgs* = ref object of Args
|
CommunityMembersArgs* = ref object of Args
|
||||||
communityId*: string
|
communityId*: string
|
||||||
members*: seq[ChatMember]
|
members*: seq[ChatMember]
|
||||||
isMember*: bool
|
|
||||||
|
|
||||||
CommunityMutedArgs* = ref object of Args
|
CommunityMutedArgs* = ref object of Args
|
||||||
communityId*: string
|
communityId*: string
|
||||||
|
@ -454,9 +453,9 @@ QtObject:
|
||||||
self.events.emit(SIGNAL_COMMUNITY_CHANNEL_EDITED, data)
|
self.events.emit(SIGNAL_COMMUNITY_CHANNEL_EDITED, data)
|
||||||
|
|
||||||
# members list was changed
|
# members list was changed
|
||||||
if community.members != prev_community.members:
|
if community.isMember and community.members != prev_community.members:
|
||||||
self.events.emit(SIGNAL_COMMUNITY_MEMBERS_CHANGED,
|
self.events.emit(SIGNAL_COMMUNITY_MEMBERS_CHANGED,
|
||||||
CommunityMembersArgs(communityId: community.id, members: community.members, isMember: community.isMember))
|
CommunityMembersArgs(communityId: community.id, members: community.members))
|
||||||
|
|
||||||
self.allCommunities[community.id] = community
|
self.allCommunities[community.id] = community
|
||||||
self.events.emit(SIGNAL_COMMUNITIES_UPDATE, CommunitiesArgs(communities: @[community]))
|
self.events.emit(SIGNAL_COMMUNITIES_UPDATE, CommunitiesArgs(communities: @[community]))
|
||||||
|
|
Loading…
Reference in New Issue