From 774da7dd4740d415912db7efa5a6083eaf5a538a Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Mon, 18 Dec 2023 13:25:30 +0100 Subject: [PATCH] fix(@desktop/general): biometrics prompt is shown after restarting the app even it was not enabled Fixes: #11261 --- src/app/global/local_account_settings.nim | 13 +++++++++++-- src/app_service/service/accounts/service.nim | 7 ++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/app/global/local_account_settings.nim b/src/app/global/local_account_settings.nim index 794b818ab7..faef2705df 100644 --- a/src/app/global/local_account_settings.nim +++ b/src/app/global/local_account_settings.nim @@ -13,6 +13,7 @@ const LS_VALUE_NEVER* = "never" QtObject: type LocalAccountSettings* = ref object of QObject settingsFileDir: string + currentFileName: string settings: QSettings proc setup(self: LocalAccountSettings) = @@ -33,8 +34,16 @@ QtObject: proc setFileName*(self: LocalAccountSettings, fileName: string) = if(not self.settings.isNil): self.settings.delete - let filePath = os.joinPath(self.settingsFileDir, fileName) - self.settings = newQSettings(filePath, QSettingsFormat.IniFormat) + let + currentFilePath = os.joinPath(self.settingsFileDir, self.currentFileName) + newFilePath = os.joinPath(self.settingsFileDir, fileName) + try: + if self.currentFileName.len > 0 and currentFilePath != newFilePath: + moveFile(currentFilePath, newFilePath) + except OSError: + discard + self.currentFileName = fileName + self.settings = newQSettings(newFilePath, QSettingsFormat.IniFormat) proc storeToKeychainValueChanged*(self: LocalAccountSettings) {.signal.} diff --git a/src/app_service/service/accounts/service.nim b/src/app_service/service/accounts/service.nim index acad9c94b0..a5667dacf5 100644 --- a/src/app_service/service/accounts/service.nim +++ b/src/app_service/service/accounts/service.nim @@ -86,6 +86,7 @@ QtObject: proc updateLoggedInAccount*(self: Service, displayName: string, images: seq[Image]) = self.loggedInAccount.name = displayName self.loggedInAccount.images = images + singletonInstance.localAccountSettings.setFileName(displayName) proc getImportedAccount*(self: Service): GeneratedAccountDto = return self.importedAccount @@ -103,8 +104,7 @@ QtObject: proc connectToFetchingFromWakuEvents*(self: Service) = self.events.on(SignalType.WakuBackedUpProfile.event) do(e: Args): var receivedData = WakuBackedUpProfileSignal(e) - self.loggedInAccount.name = receivedData.backedUpProfile.displayName - self.loggedInAccount.images = receivedData.backedUpProfile.images + self.updateLoggedInAccount(receivedData.backedUpProfile.displayName, receivedData.backedUpProfile.images) proc init*(self: Service) = try: @@ -418,7 +418,7 @@ QtObject: result["ListenAddr"] = newJString("0.0.0.0:" & $main_constants.STATUS_PORT) proc setLocalAccountSettingsFile(self: Service) = - if(main_constants.IS_MACOS and self.getLoggedInAccount.isValid()): + if self.getLoggedInAccount.isValid(): singletonInstance.localAccountSettings.setFileName(self.getLoggedInAccount.name) proc addKeycardDetails(self: Service, kcInstance: string, settingsJson: var JsonNode, accountData: var JsonNode) = @@ -778,6 +778,7 @@ QtObject: debug "Account logged in succesfully" # this should be fetched later from waku self.loggedInAccount = accToBeLoggedIn + self.setLocalAccountSettingsFile() return except Exception as e: error "error: ", procName="loginAccountKeycard", errName = e.name, errDesription = e.msg