mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-08 23:38:49 +00:00
Avoid blocking network calls at startup
This commit is contained in:
@@ -587,7 +587,7 @@ class PasswordManager:
|
|||||||
self.initialize_managers()
|
self.initialize_managers()
|
||||||
self.locked = False
|
self.locked = False
|
||||||
self.update_activity()
|
self.update_activity()
|
||||||
self.sync_index_from_nostr_if_missing()
|
self.start_background_sync()
|
||||||
|
|
||||||
def exit_managed_account(self) -> None:
|
def exit_managed_account(self) -> None:
|
||||||
"""Return to the parent seed profile if one is on the stack."""
|
"""Return to the parent seed profile if one is on the stack."""
|
||||||
@@ -1053,7 +1053,10 @@ class PasswordManager:
|
|||||||
|
|
||||||
def _worker() -> None:
|
def _worker() -> None:
|
||||||
try:
|
try:
|
||||||
self.sync_index_from_nostr()
|
if hasattr(self, "nostr_client") and hasattr(self, "vault"):
|
||||||
|
self.sync_index_from_nostr_if_missing()
|
||||||
|
if hasattr(self, "sync_index_from_nostr"):
|
||||||
|
self.sync_index_from_nostr()
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.warning(f"Background sync failed: {exc}")
|
logger.warning(f"Background sync failed: {exc}")
|
||||||
|
|
||||||
@@ -3785,29 +3788,12 @@ class PasswordManager:
|
|||||||
|
|
||||||
# Nostr sync info
|
# Nostr sync info
|
||||||
manifest = getattr(self.nostr_client, "current_manifest", None)
|
manifest = getattr(self.nostr_client, "current_manifest", None)
|
||||||
if manifest is None:
|
|
||||||
try:
|
|
||||||
result = asyncio.run(self.nostr_client.fetch_latest_snapshot())
|
|
||||||
if result:
|
|
||||||
manifest, _ = result
|
|
||||||
except Exception:
|
|
||||||
manifest = None
|
|
||||||
|
|
||||||
if manifest is not None:
|
if manifest is not None:
|
||||||
stats["chunk_count"] = len(manifest.chunks)
|
stats["chunk_count"] = len(manifest.chunks)
|
||||||
stats["delta_since"] = manifest.delta_since
|
stats["delta_since"] = manifest.delta_since
|
||||||
delta_count = 0
|
stats["pending_deltas"] = len(
|
||||||
if manifest.delta_since:
|
getattr(self.nostr_client, "_delta_events", [])
|
||||||
try:
|
)
|
||||||
version = int(manifest.delta_since)
|
|
||||||
except ValueError:
|
|
||||||
version = 0
|
|
||||||
try:
|
|
||||||
deltas = asyncio.run(self.nostr_client.fetch_deltas_since(version))
|
|
||||||
delta_count = len(deltas)
|
|
||||||
except Exception:
|
|
||||||
delta_count = 0
|
|
||||||
stats["pending_deltas"] = delta_count
|
|
||||||
else:
|
else:
|
||||||
stats["chunk_count"] = 0
|
stats["chunk_count"] = 0
|
||||||
stats["delta_since"] = None
|
stats["delta_since"] = None
|
||||||
|
Reference in New Issue
Block a user