fix(CommunitySettings): Process statuses for members model

Closes: #6132
This commit is contained in:
Boris Melnik 2022-07-04 16:58:18 +03:00
parent f798d6d0e6
commit 81e674da55
5 changed files with 27 additions and 2 deletions

View File

@ -170,6 +170,10 @@ proc init*(self: Controller) =
var args = ContactArgs(e)
self.delegate.contactUpdated(args.contactId)
self.events.on(SIGNAL_CONTACTS_STATUS_UPDATED) do(e: Args):
let args = ContactsStatusUpdatedArgs(e)
self.delegate.contactsStatusUpdated(args.statusUpdates)
self.events.on(SIGNAL_CONTACT_NICKNAME_CHANGED) do(e: Args):
var args = ContactArgs(e)
self.delegate.contactUpdated(args.contactId)
@ -302,6 +306,9 @@ proc getContactNameAndImage*(self: Controller, contactId: string):
proc getContactDetails*(self: Controller, contactId: string): ContactDetails =
return self.contactsService.getContactDetails(contactId)
proc getStatusForContact*(self: Controller, contactId: string): StatusUpdateDto =
return self.contactsService.getStatusForContactWithId(contactId)
proc resolveENS*(self: Controller, ensName: string, uuid: string = "", reason: string = "") =
self.contactsService.resolveENS(ensName, uuid, reason)

View File

@ -120,6 +120,9 @@ method communityLeft*(self: AccessInterface, communityId: string) {.base.} =
method resolvedENS*(self: AccessInterface, publicKey: string, address: string, uuid: string, reason: string) {.base.} =
raise newException(ValueError, "No implementation available")
method contactsStatusUpdated*(self: AccessInterface, statusUpdates: seq[StatusUpdateDto]) {.base.} =
raise newException(ValueError, "No implementation available")
method contactUpdated*(self: AccessInterface, publicKey: string) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -3,7 +3,7 @@ import NimQml, tables, json, sugar, sequtils, strformat, marshal, times
import io_interface, view, controller, chat_search_item, chat_search_model
import ephemeral_notification_item, ephemeral_notification_model
import ./communities/models/[pending_request_item, pending_request_model]
import ../shared_models/[member_item, member_model, section_item, section_model, active_section]
import ../shared_models/[user_item, member_item, member_model, section_item, section_model, active_section]
import ../../global/app_sections_config as conf
import ../../global/app_signals
import ../../global/global_singleton
@ -227,6 +227,8 @@ proc createChannelGroupItem[T](self: Module[T], c: ChannelGroupDto): SectionItem
c.muted,
c.members.map(proc(member: ChatMember): MemberItem =
let contactDetails = self.controller.getContactDetails(member.id)
let statusUpdateDto = self.controller.getStatusForContact(member.id)
let status = statusUpdateDto.statusType.int
result = initMemberItem(
pubKey = member.id,
displayName = contactDetails.displayName,
@ -731,6 +733,11 @@ method resolvedENS*[T](self: Module[T], publicKey: string, address: string, uuid
else:
self.view.emitResolvedENSSignal(publicKey, address, uuid)
method contactsStatusUpdated*[T](self: Module[T], statusUpdates: seq[StatusUpdateDto]) =
for s in statusUpdates:
let status = OnlineStatus(s.statusType.int)
self.view.activeSection().setOnlineStatusForMember(s.publicKey, status)
method contactUpdated*[T](self: Module[T], publicKey: string) =
let contactDetails = self.controller.getContactDetails(publicKey)
self.view.activeSection().updateMember(

View File

@ -1,5 +1,5 @@
import NimQml
import section_item
import section_item, user_item
import ../../../app_service/service/contacts/dto/contacts
QtObject:
@ -175,6 +175,10 @@ QtObject:
proc hasMember(self: ActiveSection, pubkey: string): bool {.slot.} =
return self.item.hasMember(pubkey)
proc setOnlineStatusForMember*(self: ActiveSection, pubKey: string,
onlineStatus: OnlineStatus) =
self.item.setOnlineStatusForMember(pubKey, onlineStatus)
proc updateMember*(
self: ActiveSection,
pubkey: string,

View File

@ -231,6 +231,10 @@ proc members*(self: SectionItem): member_model.Model {.inline.} =
proc hasMember*(self: SectionItem, pubkey: string): bool =
self.membersModel.isContactWithIdAdded(pubkey)
proc setOnlineStatusForMember*(self: SectionItem, pubKey: string,
onlineStatus: OnlineStatus) =
self.membersModel.setOnlineStatus(pubkey, onlineStatus)
proc updateMember*(
self: SectionItem,
pubkey: string,