From 9ef807277ee656c9929f1bd40c41f512c4577857 Mon Sep 17 00:00:00 2001 From: Michal Iskierko Date: Wed, 13 Jul 2022 11:41:09 +0200 Subject: [PATCH] fix(@desktop/chat): Fix accepting and rejecting requests Adding try/catch in a service Fix naming in QML Fix #6395 --- .../main/profile_section/contacts/view.nim | 3 +++ src/app_service/service/contacts/service.nim | 24 ++++++++++--------- .../AppLayouts/Profile/views/ContactsView.qml | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/app/modules/main/profile_section/contacts/view.nim b/src/app/modules/main/profile_section/contacts/view.nim index f37e4f6500..1eb30a557a 100644 --- a/src/app/modules/main/profile_section/contacts/view.nim +++ b/src/app/modules/main/profile_section/contacts/view.nim @@ -135,6 +135,9 @@ QtObject: proc switchToOrCreateOneToOneChat*(self: View, publicKey: string) {.slot.} = self.delegate.switchToOrCreateOneToOneChat(publicKey) + proc acceptContactRequest*(self: View, publicKey: string) {.slot.} = + self.delegate.acceptContactRequest(publicKey) + proc dismissContactRequest*(self: View, publicKey: string) {.slot.} = self.delegate.dismissContactRequest(publicKey) diff --git a/src/app_service/service/contacts/service.nim b/src/app_service/service/contacts/service.nim index 68189cca88..e46ca1c489 100644 --- a/src/app_service/service/contacts/service.nim +++ b/src/app_service/service/contacts/service.nim @@ -399,17 +399,19 @@ QtObject: error "an error occurred while accepting contact request", msg=e.msg proc dismissContactRequest*(self: Service, publicKey: string) = - # NOTE: publicKey used for dismissing last request - let response = status_contacts.dismissLatestContactRequestForContact(publicKey) - if(not response.error.isNil): - let msg = response.error.message - error "error dismissing contact ", msg - return - - var contact = self.getContactById(publicKey) - contact.removed = true - self.saveContact(contact) - self.events.emit(SIGNAL_CONTACT_REMOVED, ContactArgs(contactId: contact.id)) + try: + # NOTE: publicKey used for dismissing last request + let response = status_contacts.dismissLatestContactRequestForContact(publicKey) + if(not response.error.isNil): + let msg = response.error.message + error "error dismissing contact ", msg + return + var contact = self.getContactById(publicKey) + contact.removed = true + self.saveContact(contact) + self.events.emit(SIGNAL_CONTACT_REMOVED, ContactArgs(contactId: contact.id)) + except Exception as e: + error "an error occurred while dismissing contact request", msg=e.msg proc removeContactRequestRejection*(self: Service, publicKey: string) = var contact = self.getContactById(publicKey) diff --git a/ui/app/AppLayouts/Profile/views/ContactsView.qml b/ui/app/AppLayouts/Profile/views/ContactsView.qml index 9519e47617..2d5ae93872 100644 --- a/ui/app/AppLayouts/Profile/views/ContactsView.qml +++ b/ui/app/AppLayouts/Profile/views/ContactsView.qml @@ -176,7 +176,7 @@ SettingsContentBase { } onContactRequestRejected: { - root.contactsStore.rejectContactRequest(publicKey) + root.contactsStore.dismissContactRequest(publicKey) } onShowVerificationRequest: {