diff --git a/src/app/login/view.nim b/src/app/login/view.nim index 7c05c1eecc..6849e0f5cc 100644 --- a/src/app/login/view.nim +++ b/src/app/login/view.nim @@ -62,7 +62,6 @@ QtObject: keyUid: currNodeAcct.keyUid, identityImage: currNodeAcct.identityImage )) - self.status.events.emit("currentAccountUpdated", AccountArgs(account: currNodeAcct)) QtProperty[QVariant] currentAccount: read = getCurrentAccount diff --git a/src/app/onboarding/view.nim b/src/app/onboarding/view.nim index 7aad09fb8e..7d51f5d4e9 100644 --- a/src/app/onboarding/view.nim +++ b/src/app/onboarding/view.nim @@ -100,10 +100,7 @@ QtObject: result = self.status.wallet.validateMnemonic(mnemonic.strip()) proc storeDerivedAndLogin(self: OnboardingView, password: string): string {.slot.} = - # In this moment we're sure that new account will be logged in, and emit signal. let genAcc = self.currentAccount.account - let acc = Account(name: genAcc.name, keyUid: genAcc.keyUid, identicon: genAcc.identicon, identityImage: genAcc.identityImage) - self.status.events.emit("currentAccountUpdated", status_account_type.AccountArgs(account: acc)) try: result = self.status.accounts.storeDerivedAndLogin(self.status.fleet.config, genAcc, password).toJson diff --git a/src/app/profile/core.nim b/src/app/profile/core.nim index 2d9b924575..947eafe8a0 100644 --- a/src/app/profile/core.nim +++ b/src/app/profile/core.nim @@ -35,9 +35,6 @@ proc delete*(self: ProfileController) = delete self.variant delete self.view -proc setSettingsFile*(self: ProfileController, username: string) = - self.view.setSettingsFile(username) - proc init*(self: ProfileController, account: Account) = let profile = account.toProfileModel() @@ -62,6 +59,7 @@ proc init*(self: ProfileController, account: Account) = self.view.devices.addDevices(status_devices.getAllDevices()) self.view.devices.setDeviceSetup(status_devices.isDeviceSetup()) self.view.setNewProfile(profile) + self.view.setSettingsFile(profile.id) self.view.network.setNetwork(network) self.view.ens.init() self.view.initialized() diff --git a/src/app/profile/view.nim b/src/app/profile/view.nim index 25be032355..bd0feb92e5 100644 --- a/src/app/profile/view.nim +++ b/src/app/profile/view.nim @@ -184,23 +184,6 @@ QtObject: QtProperty[QVariant] picture: read = getProfilePicture - proc settingsFileChanged*(self: ProfileView) {.signal.} - - proc getSettingsFile*(self: ProfileView): string {.slot.} = - self.appService.localSettingsService.getSettingsFilePath - - proc setSettingsFile*(self: ProfileView, username: string) = - if(username.len == 0 or - self.appService.localSettingsService.getSettingsFilePath.endsWith(username)): - return - - self.appService.localSettingsService.updateSettingsFilePath(username) - self.settingsFileChanged() - - QtProperty[string] settingsFile: - read = getSettingsFile - notify = settingsFileChanged - proc getGlobalSettingsFile*(self: ProfileView): string {.slot.} = self.appService.localSettingsService.getGlobalSettingsFilePath @@ -213,6 +196,19 @@ QtObject: QtProperty[QVariant] mutedChats: read = getMutedChats + proc settingsFileChanged*(self: ProfileView) {.signal.} + + proc getSettingsFile*(self: ProfileView): string {.slot.} = + self.appService.localSettingsService.getSettingsFilePath + + proc setSettingsFile*(self: ProfileView, pubKey: string) = + self.appService.localSettingsService.updateSettingsFilePath(pubKey) + self.settingsFileChanged() + + QtProperty[string] settingsFile: + read = getSettingsFile + notify = settingsFileChanged + proc setSendUserStatus*(self: ProfileView, sendUserStatus: bool) {.slot.} = if (sendUserStatus == self.profile.sendUserStatus): return diff --git a/src/app_service/service/local_settings/service.nim b/src/app_service/service/local_settings/service.nim index a0a090d3c3..0bc42a13c9 100644 --- a/src/app_service/service/local_settings/service.nim +++ b/src/app_service/service/local_settings/service.nim @@ -40,17 +40,16 @@ QtObject: proc getSettingsFilePath*(self: LocalSettingsService): string = return self.settingsFilePath - proc updateSettingsFilePath*(self: LocalSettingsService, username: string) = - if (username.len > 0): - let unknownSettingsPath = os.joinPath(DATADIR, "qt", UNKNOWN_ACCOUNT) - if (not unknownSettingsPath.tryRemoveFile): - # Only fails if the file exists and an there was an error removing it - # More info: https://nim-lang.org/docs/os.html#tryRemoveFile%2Cstring - warn "Failed to remove unused settings file", file=unknownSettingsPath + proc updateSettingsFilePath*(self: LocalSettingsService, pubKey: string) = + let unknownSettingsPath = os.joinPath(DATADIR, "qt", UNKNOWN_ACCOUNT) + if (not unknownSettingsPath.tryRemoveFile): + # Only fails if the file exists and an there was an error removing it + # More info: https://nim-lang.org/docs/os.html#tryRemoveFile%2Cstring + warn "Failed to remove unused settings file", file=unknownSettingsPath - self.settings.delete - self.settingsFilePath = os.joinPath(DATADIR, "qt", username) - self.settings = newQSettings(self.settingsFilePath, QSettingsFormat.IniFormat) + self.settings.delete + self.settingsFilePath = os.joinPath(DATADIR, "qt", pubKey) + self.settings = newQSettings(self.settingsFilePath, QSettingsFormat.IniFormat) proc setValue*(self: LocalSettingsService, key: string, value: QVariant) = self.settings.setValue(key, value) diff --git a/src/nim_status_client.nim b/src/nim_status_client.nim index b50dc75732..f41147c093 100644 --- a/src/nim_status_client.nim +++ b/src/nim_status_client.nim @@ -194,7 +194,6 @@ proc mainProc() = status.events.once("login") do(a: Args): var args = AccountArgs(a) - appService.onLoggedIn() # Reset login and onboarding to remove any mnemonic that would have been saved in the accounts list @@ -205,17 +204,9 @@ proc mainProc() = onboarding.moveToAppState() status.events.emit("loginCompleted", args) - proc updateProfileSettings(account: Account) = - profile.setSettingsFile(account.name) - - status.events.on("currentAccountUpdated") do(a: Args): - var args = AccountArgs(a) - updateProfileSettings(args.account) - status.events.once("loginCompleted") do(a: Args): var args = AccountArgs(a) - updateProfileSettings(args.account) status.startMessenger() profile.init(args.account) wallet.init()