Cache system added using sqlite. Should be nicer to the server.
This commit is contained in:
@@ -3,6 +3,8 @@ Accessible text display dialog - single point of truth for showing text to scree
|
||||
Based on the implementation from Bifrost
|
||||
"""
|
||||
|
||||
import time
|
||||
|
||||
from PySide6.QtWidgets import (
|
||||
QDialog, QVBoxLayout, QTextEdit, QDialogButtonBox
|
||||
)
|
||||
@@ -15,6 +17,11 @@ class AccessibleTextDialog(QDialog):
|
||||
Provides keyboard navigation, text selection, and proper focus management.
|
||||
"""
|
||||
|
||||
# Class-level error debouncing to prevent dialog spam
|
||||
_lastErrorKey: str = ""
|
||||
_lastErrorTime: float = 0.0
|
||||
_errorDebounceSeconds: float = 2.0
|
||||
|
||||
def __init__(self, title: str, content: str, dialogType: str = "info", parent=None):
|
||||
"""
|
||||
Initialize accessible text dialog
|
||||
@@ -80,7 +87,21 @@ class AccessibleTextDialog(QDialog):
|
||||
|
||||
@classmethod
|
||||
def showError(cls, title: str, message: str, details: str = None, parent=None):
|
||||
"""Convenience method for error dialogs with optional details"""
|
||||
"""Convenience method for error dialogs with optional details.
|
||||
|
||||
Includes debouncing to prevent the same error from spawning multiple dialogs
|
||||
in rapid succession.
|
||||
"""
|
||||
# Debounce: skip if same error within debounce window
|
||||
errorKey = f"{title}:{message}"
|
||||
currentTime = time.monotonic()
|
||||
if (errorKey == cls._lastErrorKey and
|
||||
currentTime - cls._lastErrorTime < cls._errorDebounceSeconds):
|
||||
return
|
||||
|
||||
cls._lastErrorKey = errorKey
|
||||
cls._lastErrorTime = currentTime
|
||||
|
||||
if details:
|
||||
content = f"{message}\n\nError Details:\n{details}"
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user