fix(1-1): fix contact label not updating when mutual contact changes
Fixes #5709
This commit is contained in:
parent
e6f809b921
commit
416cedd033
|
@ -17,6 +17,7 @@ QtObject:
|
||||||
notificationsCount: int
|
notificationsCount: int
|
||||||
muted: bool
|
muted: bool
|
||||||
position: int
|
position: int
|
||||||
|
isMutualContact: bool
|
||||||
|
|
||||||
proc delete*(self: ChatDetails) =
|
proc delete*(self: ChatDetails) =
|
||||||
self.QObject.delete
|
self.QObject.delete
|
||||||
|
@ -26,8 +27,9 @@ QtObject:
|
||||||
result.QObject.setup
|
result.QObject.setup
|
||||||
|
|
||||||
proc setChatDetails*(self: ChatDetails, id: string, `type`: int, belongsToCommunity,
|
proc setChatDetails*(self: ChatDetails, id: string, `type`: int, belongsToCommunity,
|
||||||
isUsersListAvailable: bool, name, icon: string, color, description,
|
isUsersListAvailable: bool, name, icon: string, color, description,
|
||||||
emoji: string, hasUnreadMessages: bool, notificationsCount: int, muted: bool, position: int) =
|
emoji: string, hasUnreadMessages: bool, notificationsCount: int, muted: bool, position: int,
|
||||||
|
isMutualContact: bool = false) =
|
||||||
self.id = id
|
self.id = id
|
||||||
self.`type` = `type`
|
self.`type` = `type`
|
||||||
self.belongsToCommunity = belongsToCommunity
|
self.belongsToCommunity = belongsToCommunity
|
||||||
|
@ -41,6 +43,7 @@ QtObject:
|
||||||
self.notificationsCount = notificationsCount
|
self.notificationsCount = notificationsCount
|
||||||
self.muted = muted
|
self.muted = muted
|
||||||
self.position = position
|
self.position = position
|
||||||
|
self.isMutualContact = isMutualContact
|
||||||
|
|
||||||
proc getId(self: ChatDetails): string {.slot.} =
|
proc getId(self: ChatDetails): string {.slot.} =
|
||||||
return self.id
|
return self.id
|
||||||
|
@ -160,3 +163,14 @@ QtObject:
|
||||||
proc setPotion*(self: ChatDetails, value: int) = # this is not a slot
|
proc setPotion*(self: ChatDetails, value: int) = # this is not a slot
|
||||||
self.position = value
|
self.position = value
|
||||||
self.positionChanged()
|
self.positionChanged()
|
||||||
|
|
||||||
|
proc isMutualContactChanged(self: ChatDetails) {.signal.}
|
||||||
|
proc getIsMutualContact(self: ChatDetails): bool {.slot.} =
|
||||||
|
return self.isMutualContact
|
||||||
|
QtProperty[bool] isMutualContact:
|
||||||
|
read = getIsMutualContact
|
||||||
|
notify = isMutualContactChanged
|
||||||
|
|
||||||
|
proc setIsMutualContact*(self: ChatDetails, value: bool) = # this is not a slot
|
||||||
|
self.isMutualContact = value
|
||||||
|
self.isMutualContactChanged()
|
||||||
|
|
|
@ -30,6 +30,9 @@ type
|
||||||
communityService: community_service.Service
|
communityService: community_service.Service
|
||||||
messageService: message_service.Service
|
messageService: message_service.Service
|
||||||
|
|
||||||
|
# Forward declaration
|
||||||
|
proc getChatDetails*(self: Controller): ChatDto
|
||||||
|
|
||||||
proc newController*(delegate: io_interface.AccessInterface, events: EventEmitter, sectionId: string, chatId: string,
|
proc newController*(delegate: io_interface.AccessInterface, events: EventEmitter, sectionId: string, chatId: string,
|
||||||
belongsToCommunity: bool, isUsersListAvailable: bool, settingsService: settings_service.Service,
|
belongsToCommunity: bool, isUsersListAvailable: bool, settingsService: settings_service.Service,
|
||||||
contactService: contact_service.Service, chatService: chat_service.Service,
|
contactService: contact_service.Service, chatService: chat_service.Service,
|
||||||
|
@ -106,6 +109,30 @@ proc init*(self: Controller) =
|
||||||
self.events.on(SIGNAL_CONTACT_UPDATED) do(e: Args):
|
self.events.on(SIGNAL_CONTACT_UPDATED) do(e: Args):
|
||||||
var args = ContactArgs(e)
|
var args = ContactArgs(e)
|
||||||
self.delegate.onContactDetailsUpdated(args.contactId)
|
self.delegate.onContactDetailsUpdated(args.contactId)
|
||||||
|
if (args.contactId == self.chatId):
|
||||||
|
self.delegate.onMutualContactChanged()
|
||||||
|
|
||||||
|
let chatDto = self.getChatDetails()
|
||||||
|
if(chatDto.chatType == ChatType.OneToOne):
|
||||||
|
self.events.on(SIGNAL_CONTACT_ADDED) do(e: Args):
|
||||||
|
var args = ContactArgs(e)
|
||||||
|
if (args.contactId == self.chatId):
|
||||||
|
self.delegate.onMutualContactChanged()
|
||||||
|
|
||||||
|
self.events.on(SIGNAL_CONTACT_REMOVED) do(e: Args):
|
||||||
|
var args = ContactArgs(e)
|
||||||
|
if (args.contactId == self.chatId):
|
||||||
|
self.delegate.onMutualContactChanged()
|
||||||
|
|
||||||
|
self.events.on(SIGNAL_CONTACT_BLOCKED) do(e: Args):
|
||||||
|
var args = ContactArgs(e)
|
||||||
|
if (args.contactId == self.chatId):
|
||||||
|
self.delegate.onMutualContactChanged()
|
||||||
|
|
||||||
|
self.events.on(SIGNAL_CONTACT_UNBLOCKED) do(e: Args):
|
||||||
|
var args = ContactArgs(e)
|
||||||
|
if (args.contactId == self.chatId):
|
||||||
|
self.delegate.onMutualContactChanged()
|
||||||
|
|
||||||
self.events.on(SIGNAL_MESSAGE_DELETION) do(e: Args):
|
self.events.on(SIGNAL_MESSAGE_DELETION) do(e: Args):
|
||||||
let args = MessageDeletedArgs(e)
|
let args = MessageDeletedArgs(e)
|
||||||
|
|
|
@ -111,3 +111,6 @@ method amIChatAdmin*(self: AccessInterface): bool {.base.} =
|
||||||
|
|
||||||
method downloadMessages*(self: AccessInterface, filePath: string) =
|
method downloadMessages*(self: AccessInterface, filePath: string) =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method onMutualContactChanged*(self: AccessInterface) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
|
@ -75,13 +75,18 @@ method load*(self: Module) =
|
||||||
let notificationsCount = chatDto.unviewedMentionsCount
|
let notificationsCount = chatDto.unviewedMentionsCount
|
||||||
var chatName = chatDto.name
|
var chatName = chatDto.name
|
||||||
var chatImage = chatDto.icon
|
var chatImage = chatDto.icon
|
||||||
|
var isMutualContact = false
|
||||||
if(chatDto.chatType == ChatType.OneToOne):
|
if(chatDto.chatType == ChatType.OneToOne):
|
||||||
(chatName, chatImage) = self.controller.getOneToOneChatNameAndImage()
|
let contactDto = self.controller.getContactById(self.controller.getMyChatId())
|
||||||
|
chatName = contactDto.userNameOrAlias()
|
||||||
|
isMutualContact = contactDto.isMutualContact
|
||||||
|
if(contactDto.image.thumbnail.len > 0):
|
||||||
|
chatImage = contactDto.image.thumbnail
|
||||||
|
|
||||||
self.view.load(chatDto.id, chatDto.chatType.int, self.controller.belongsToCommunity(),
|
self.view.load(chatDto.id, chatDto.chatType.int, self.controller.belongsToCommunity(),
|
||||||
self.controller.isUsersListAvailable(), chatName, chatImage,
|
self.controller.isUsersListAvailable(), chatName, chatImage,
|
||||||
chatDto.color, chatDto.description, chatDto.emoji, hasNotification, notificationsCount,
|
chatDto.color, chatDto.description, chatDto.emoji, hasNotification, notificationsCount,
|
||||||
chatDto.muted, chatDto.position)
|
chatDto.muted, chatDto.position, isMutualContact)
|
||||||
|
|
||||||
self.inputAreaModule.load()
|
self.inputAreaModule.load()
|
||||||
self.messagesModule.load()
|
self.messagesModule.load()
|
||||||
|
@ -335,3 +340,8 @@ method onChatRenamed*(self: Module, newName: string) =
|
||||||
method downloadMessages*(self: Module, filePath: string) =
|
method downloadMessages*(self: Module, filePath: string) =
|
||||||
let messages = self.messagesModule.getMessages()
|
let messages = self.messagesModule.getMessages()
|
||||||
self.controller.downloadMessages(messages, filePath)
|
self.controller.downloadMessages(messages, filePath)
|
||||||
|
|
||||||
|
method onMutualContactChanged*(self: Module) =
|
||||||
|
let contactDto = self.controller.getContactById(self.controller.getMyChatId())
|
||||||
|
let isMutualContact = contactDto.isMutualContact
|
||||||
|
self.view.onMutualContactChanged(isMutualContact)
|
||||||
|
|
|
@ -31,10 +31,10 @@ QtObject:
|
||||||
result.chatDetailsVariant = newQVariant(result.chatDetails)
|
result.chatDetailsVariant = newQVariant(result.chatDetails)
|
||||||
|
|
||||||
proc load*(self: View, id: string, `type`: int, belongsToCommunity, isUsersListAvailable: bool,
|
proc load*(self: View, id: string, `type`: int, belongsToCommunity, isUsersListAvailable: bool,
|
||||||
name, icon: string, color, description, emoji: string,
|
name, icon: string, color, description, emoji: string, hasUnreadMessages: bool,
|
||||||
hasUnreadMessages: bool, notificationsCount: int, muted: bool, position: int) =
|
notificationsCount: int, muted: bool, position: int, isMutualContact: bool) =
|
||||||
self.chatDetails.setChatDetails(id, `type`, belongsToCommunity, isUsersListAvailable, name, icon,
|
self.chatDetails.setChatDetails(id, `type`, belongsToCommunity, isUsersListAvailable, name, icon,
|
||||||
color, description, emoji, hasUnreadMessages, notificationsCount, muted, position)
|
color, description, emoji, hasUnreadMessages, notificationsCount, muted, position, isMutualContact)
|
||||||
self.delegate.viewDidLoad()
|
self.delegate.viewDidLoad()
|
||||||
self.chatDetailsChanged()
|
self.chatDetailsChanged()
|
||||||
|
|
||||||
|
@ -123,5 +123,8 @@ QtObject:
|
||||||
self.chatDetails.setName(name)
|
self.chatDetails.setName(name)
|
||||||
self.chatDetailsChanged()
|
self.chatDetailsChanged()
|
||||||
|
|
||||||
|
proc onMutualContactChanged*(self: View, value: bool) =
|
||||||
|
self.chatDetails.setIsMutualContact(value)
|
||||||
|
|
||||||
proc downloadMessages*(self: View, filePath: string) {.slot.} =
|
proc downloadMessages*(self: View, filePath: string) {.slot.} =
|
||||||
self.delegate.downloadMessages(filePath)
|
self.delegate.downloadMessages(filePath)
|
|
@ -120,7 +120,7 @@ proc isBlocked*(self: ContactsDto): bool =
|
||||||
proc isMutualContact*(self: ContactsDto): bool =
|
proc isMutualContact*(self: ContactsDto): bool =
|
||||||
# TODO not implemented in `status-go` yet
|
# TODO not implemented in `status-go` yet
|
||||||
# But for now we consider that contact is mutual contact if I added him and he added me.
|
# But for now we consider that contact is mutual contact if I added him and he added me.
|
||||||
return self.hasAddedUs and self.added
|
return self.hasAddedUs and self.added and not self.removed and not self.blocked
|
||||||
|
|
||||||
proc isContactVerified*(self: ContactsDto): bool =
|
proc isContactVerified*(self: ContactsDto): bool =
|
||||||
# TODO not implemented in `status-go` yet
|
# TODO not implemented in `status-go` yet
|
||||||
|
|
|
@ -197,9 +197,7 @@ QtObject:
|
||||||
elif (group == ContactsGroup.MyMutualContacts):
|
elif (group == ContactsGroup.MyMutualContacts):
|
||||||
# we need to revise this when we introduce "identity verification" feature
|
# we need to revise this when we introduce "identity verification" feature
|
||||||
return contacts.filter(x => x.id != myPubKey and
|
return contacts.filter(x => x.id != myPubKey and
|
||||||
x.isMutualContact() and
|
x.isMutualContact())
|
||||||
not x.isContactRemoved() and
|
|
||||||
not x.isBlocked())
|
|
||||||
elif (group == ContactsGroup.AllKnownContacts):
|
elif (group == ContactsGroup.AllKnownContacts):
|
||||||
return contacts
|
return contacts
|
||||||
|
|
||||||
|
@ -322,6 +320,7 @@ QtObject:
|
||||||
|
|
||||||
var contact = self.getContactById(publicKey)
|
var contact = self.getContactById(publicKey)
|
||||||
contact.added = true
|
contact.added = true
|
||||||
|
contact.removed = false
|
||||||
self.saveContact(contact)
|
self.saveContact(contact)
|
||||||
self.events.emit(SIGNAL_CONTACT_ADDED, ContactArgs(contactId: contact.id))
|
self.events.emit(SIGNAL_CONTACT_ADDED, ContactArgs(contactId: contact.id))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue