✨ feat(notifications): add function to clear all notification history

This commit is contained in:
sankalp committed 2025-07-27 02:08:04 +05:45
1 parent d207ef5008
commit f82cb69577
1 file changed
+19
+19
View File
@@ -394,6 +394,25 @@ class NotificationHistory(Box):
except Exception as e:
print(f"Error clearing history for app {app_name}: {e}")
def clear_history(self):
"""Clear all notification history"""
try:
# Clear cached images for all notifications
for notif in self.persistent_notifications:
cached_image_path = notif.get("cached_image_path")
if cached_image_path:
delete_cached_image(cached_image_path)
# Clear the persistent notifications list
self.persistent_notifications.clear()
# Save the empty history
self._save_persistent_history()
logger.info("Cleared all notification history")
except Exception as e:
print(f"Error clearing notification history: {e}")
def get_shared_notification_history():
"""Get or create the shared notification history instance"""