mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-08 15:28:44 +00:00
Add notification queue to PasswordManager
This commit is contained in:
@@ -20,6 +20,8 @@ import shutil
|
|||||||
import time
|
import time
|
||||||
import builtins
|
import builtins
|
||||||
import threading
|
import threading
|
||||||
|
import queue
|
||||||
|
from dataclasses import dataclass
|
||||||
from termcolor import colored
|
from termcolor import colored
|
||||||
from utils.color_scheme import color_text
|
from utils.color_scheme import color_text
|
||||||
from utils.input_utils import timed_input
|
from utils.input_utils import timed_input
|
||||||
@@ -96,6 +98,14 @@ from password_manager.config_manager import ConfigManager
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Notification:
|
||||||
|
"""Simple message container for UI notifications."""
|
||||||
|
|
||||||
|
message: str
|
||||||
|
level: str = "INFO"
|
||||||
|
|
||||||
|
|
||||||
class PasswordManager:
|
class PasswordManager:
|
||||||
"""
|
"""
|
||||||
PasswordManager Class
|
PasswordManager Class
|
||||||
@@ -126,6 +136,7 @@ class PasswordManager:
|
|||||||
self.bip85: Optional[BIP85] = None
|
self.bip85: Optional[BIP85] = None
|
||||||
self.nostr_client: Optional[NostrClient] = None
|
self.nostr_client: Optional[NostrClient] = None
|
||||||
self.config_manager: Optional[ConfigManager] = None
|
self.config_manager: Optional[ConfigManager] = None
|
||||||
|
self.notifications: queue.Queue[Notification] = queue.Queue()
|
||||||
|
|
||||||
# Track changes to trigger periodic Nostr sync
|
# Track changes to trigger periodic Nostr sync
|
||||||
self.is_dirty: bool = False
|
self.is_dirty: bool = False
|
||||||
@@ -216,6 +227,10 @@ class PasswordManager:
|
|||||||
"""Record the current time as the last user activity."""
|
"""Record the current time as the last user activity."""
|
||||||
self.last_activity = time.time()
|
self.last_activity = time.time()
|
||||||
|
|
||||||
|
def notify(self, message: str, level: str = "INFO") -> None:
|
||||||
|
"""Enqueue a notification for later retrieval."""
|
||||||
|
self.notifications.put(Notification(message, level))
|
||||||
|
|
||||||
def lock_vault(self) -> None:
|
def lock_vault(self) -> None:
|
||||||
"""Clear sensitive information from memory."""
|
"""Clear sensitive information from memory."""
|
||||||
if self.entry_manager is not None:
|
if self.entry_manager is not None:
|
||||||
@@ -1076,12 +1091,10 @@ class PasswordManager:
|
|||||||
):
|
):
|
||||||
healthy = self.nostr_client.check_relay_health(MIN_HEALTHY_RELAYS)
|
healthy = self.nostr_client.check_relay_health(MIN_HEALTHY_RELAYS)
|
||||||
if healthy < MIN_HEALTHY_RELAYS:
|
if healthy < MIN_HEALTHY_RELAYS:
|
||||||
print(
|
self.notify(
|
||||||
colored(
|
f"Only {healthy} relay(s) responded with your latest event."
|
||||||
f"Only {healthy} relay(s) responded with your latest event."
|
" Consider adding more relays via Settings.",
|
||||||
" Consider adding more relays via Settings.",
|
level="WARNING",
|
||||||
"yellow",
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.warning(f"Relay health check failed: {exc}")
|
logger.warning(f"Relay health check failed: {exc}")
|
||||||
|
Reference in New Issue
Block a user