qt: keep list of recently used wallets in sync across windows
this also removes alpha-sort of the wallet list in favor of placing most recently opened on top
This commit is contained in:
@@ -497,6 +497,7 @@ class Daemon(Logger):
|
||||
wallet = self._load_wallet(path, password, upgrade=upgrade, config=self.config)
|
||||
wallet.start_network(self.network)
|
||||
self.add_wallet(wallet)
|
||||
self.update_recently_opened_wallets(path)
|
||||
return wallet
|
||||
|
||||
@staticmethod
|
||||
@@ -542,6 +543,7 @@ class Daemon(Logger):
|
||||
self.stop_wallet(path)
|
||||
if os.path.exists(path):
|
||||
os.unlink(path)
|
||||
self.update_recently_opened_wallets(path, remove=True)
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -704,3 +706,14 @@ class Daemon(Logger):
|
||||
self._check_password_for_directory(
|
||||
old_password=old_password, new_password=new_password, wallet_dir=wallet_dir)
|
||||
return True
|
||||
|
||||
def update_recently_opened_wallets(self, wallet_path, *, remove: bool = False):
|
||||
recent = self.config.RECENTLY_OPEN_WALLET_FILES or []
|
||||
if wallet_path in recent:
|
||||
recent.remove(wallet_path)
|
||||
if not remove:
|
||||
recent.insert(0, wallet_path)
|
||||
recent = [path for path in recent if os.path.exists(path)]
|
||||
recent = recent[:5]
|
||||
self.config.RECENTLY_OPEN_WALLET_FILES = recent
|
||||
util.trigger_callback('recently_opened_wallets_update')
|
||||
|
||||
Reference in New Issue
Block a user