From a306d3a9d76cfeb719fea9a620c05fcbf503878f Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Thu, 27 Jan 2022 10:11:18 -0500 Subject: [PATCH] fix(profile): fix profile seed phrase backup badge Fixes #4573 --- src/app/modules/main/controller.nim | 12 +++++++++++- src/app/modules/main/controller_interface.nim | 5 ++++- src/app/modules/main/module.nim | 17 +++++++++++++++-- .../module_access_interface.nim | 3 +++ .../module_controller_delegate_interface.nim | 3 +++ src/app/modules/shared_models/section_item.nim | 4 ++-- 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/app/modules/main/controller.nim b/src/app/modules/main/controller.nim index b918ba5105..a3958ce5c5 100644 --- a/src/app/modules/main/controller.nim +++ b/src/app/modules/main/controller.nim @@ -11,6 +11,7 @@ import ../../../app_service/service/community/service as community_service import ../../../app_service/service/contacts/service as contacts_service import ../../../app_service/service/message/service as message_service import ../../../app_service/service/gif/service as gif_service +import ../../../app_service/service/privacy/service as privacy_service export controller_interface @@ -29,6 +30,7 @@ type messageService: message_service.Service contactsService: contacts_service.Service gifService: gif_service.Service + privacyService: privacy_service.Service activeSectionId: string proc newController*(delegate: io_interface.AccessInterface, @@ -41,6 +43,7 @@ proc newController*(delegate: io_interface.AccessInterface, contactsService: contacts_service.Service, messageService: message_service.Service, gifService: gif_service.Service, + privacyService: privacy_service.Service, ): Controller = result = Controller() @@ -54,6 +57,7 @@ proc newController*(delegate: io_interface.AccessInterface, result.contactsService = contactsService result.messageService = messageService result.gifService = gifService + result.privacyService = privacyService method delete*(self: Controller) = discard @@ -134,6 +138,9 @@ method init*(self: Controller) = var args = ContactArgs(e) self.delegate.contactUpdated(args.contactId) + self.events.on(SIGNAL_MNEMONIC_REMOVAL) do(e: Args): + self.delegate.mnemonicBackedUp() + method getJoinedCommunities*(self: Controller): seq[CommunityDto] = return self.communityService.getJoinedCommunities() @@ -213,4 +220,7 @@ method getContactNameAndImage*(self: Controller, contactId: string): return self.contactsService.getContactNameAndImage(contactId) method resolveENS*(self: Controller, ensName: string, uuid: string = "") = - self.contactsService.resolveENS(ensName, uuid) \ No newline at end of file + self.contactsService.resolveENS(ensName, uuid) + +method isMnemonicBackedUp*(self: Controller): bool = + result = self.privacyService.isMnemonicBackedUp() \ No newline at end of file diff --git a/src/app/modules/main/controller_interface.nim b/src/app/modules/main/controller_interface.nim index 98622cce28..e79f4b5cd8 100644 --- a/src/app/modules/main/controller_interface.nim +++ b/src/app/modules/main/controller_interface.nim @@ -44,5 +44,8 @@ method getContactNameAndImage*(self: AccessInterface, contactId: string): tuple[name: string, image: string, isIdenticon: bool] {.base.} = raise newException(ValueError, "No implementation available") -method resolveENS*(self: AccessInterface, ensName: string, uuid: string = ""): void {.base.} = +method resolveENS*(self: AccessInterface, ensName: string, uuid: string = "") {.base.} = + raise newException(ValueError, "No implementation available") + +method isMnemonicBackedUp*(self: AccessInterface): bool {.base.} = raise newException(ValueError, "No implementation available") \ No newline at end of file diff --git a/src/app/modules/main/module.nim b/src/app/modules/main/module.nim index 5eb358696b..cf8bcea01d 100644 --- a/src/app/modules/main/module.nim +++ b/src/app/modules/main/module.nim @@ -68,6 +68,9 @@ type nodeSectionModule: node_section_module.AccessInterface moduleLoaded: bool +# Forward declaration +method calculateProfileSectionHasNotification*[T](self: Module[T]): bool + proc newModule*[T]( delegate: T, events: EventEmitter, @@ -114,6 +117,7 @@ proc newModule*[T]( contactsService, messageService, gifService, + privacyService, ) result.moduleLoaded = false @@ -321,7 +325,7 @@ method load*[T]( image = "", conf.SETTINGS_SECTION_ICON, color = "", - hasNotification = false, + hasNotification = self.calculateProfileSectionHasNotification(), notificationsCount = 0, active = false, enabled = true) @@ -598,4 +602,13 @@ method resolvedENS*[T](self: Module[T], publicKey: string, address: string, uuid method contactUpdated*[T](self: Module[T], publicKey: string) = let (name, image, isIdenticon) = self.controller.getContactNameAndImage(publicKey) - self.view.activeSection().updateMember(publicKey, name, image, isIdenticon) \ No newline at end of file + self.view.activeSection().updateMember(publicKey, name, image, isIdenticon) + +method calculateProfileSectionHasNotification*[T](self: Module[T]): bool = + return not self.controller.isMnemonicBackedUp() + +method mnemonicBackedUp*[T](self: Module[T]) = + self.view.model().udpateNotifications( + conf.SETTINGS_SECTION_ID, + self.calculateProfileSectionHasNotification(), + notificationsCount = 0) \ No newline at end of file diff --git a/src/app/modules/main/private_interfaces/module_access_interface.nim b/src/app/modules/main/private_interfaces/module_access_interface.nim index 80b2947e0f..423ce0ca0c 100644 --- a/src/app/modules/main/private_interfaces/module_access_interface.nim +++ b/src/app/modules/main/private_interfaces/module_access_interface.nim @@ -24,4 +24,7 @@ method load*( raise newException(ValueError, "No implementation available") method checkForStoringPassword*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method calculateProfileSectionHasNotification*(self: AccessInterface): bool {.base.} = raise newException(ValueError, "No implementation available") \ No newline at end of file diff --git a/src/app/modules/main/private_interfaces/module_controller_delegate_interface.nim b/src/app/modules/main/private_interfaces/module_controller_delegate_interface.nim index 8661361bbf..b733fa24c9 100644 --- a/src/app/modules/main/private_interfaces/module_controller_delegate_interface.nim +++ b/src/app/modules/main/private_interfaces/module_controller_delegate_interface.nim @@ -35,3 +35,6 @@ method resolvedENS*(self: AccessInterface, publicKey: string, address: string, u method contactUpdated*(self: AccessInterface, publicKey: string) {.base.} = raise newException(ValueError, "No implementation available") + +method mnemonicBackedUp*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/shared_models/section_item.nim b/src/app/modules/shared_models/section_item.nim index 9a959872c2..9b51d0205a 100644 --- a/src/app/modules/shared_models/section_item.nim +++ b/src/app/modules/shared_models/section_item.nim @@ -134,10 +134,10 @@ proc icon*(self: SectionItem): string {.inline.} = proc color*(self: SectionItem): string {.inline.} = self.color -proc hasNotification*(self: SectionItem): bool {.inline.} = +proc hasNotification*(self: SectionItem): bool {.inline.} = self.hasNotification -proc `hasNotification=`*(self: var SectionItem, value: bool) {.inline.} = +proc `hasNotification=`*(self: var SectionItem, value: bool) {.inline.} = self.hasNotification = value proc notificationsCount*(self: SectionItem): int {.inline.} =