Cleanup of all images in stack in notification_center
This commit is contained in:
1 parent
e51878cac5
commit
d0189d44b4
1 file changed
+38
-24
@@ -418,15 +418,22 @@ class ExpandableNotificationGroup(Box):
|
|||||||
return False # Don't repeat timeout
|
return False # Don't repeat timeout
|
||||||
|
|
||||||
def close_all(self, *args):
|
def close_all(self, *args):
|
||||||
|
"""Close all notifications in this group with proper cache cleanup"""
|
||||||
# Close all notifications in this group
|
# Close all notifications in this group
|
||||||
for notification in self.notifications:
|
for notification in self.notifications:
|
||||||
try:
|
try:
|
||||||
cleanup_notification_specific_caches(
|
# Get notification ID for cache cleanup
|
||||||
app_icon_source=getattr(notification, "app_icon_source", None),
|
notification_id = getattr(notification._notification, "id", None)
|
||||||
notification_image_cache_key=getattr(
|
app_icon_source = getattr(notification._notification, "app_icon", None)
|
||||||
notification, "notification_image_cache_key", None
|
|
||||||
),
|
# Clean up caches using notification ID pattern
|
||||||
)
|
if notification_id:
|
||||||
|
cleanup_notification_specific_caches(
|
||||||
|
app_icon_source=app_icon_source,
|
||||||
|
notification_image_cache_key=f"notif_{notification_id}_*"
|
||||||
|
)
|
||||||
|
logger.debug(f"Cleaned up caches for notification ID: {notification_id}")
|
||||||
|
|
||||||
notification_service.remove_cached_notification(notification.cache_id)
|
notification_service.remove_cached_notification(notification.cache_id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(
|
logger.error(
|
||||||
@@ -434,14 +441,20 @@ class ExpandableNotificationGroup(Box):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def _close_single_notification(self, notification):
|
def _close_single_notification(self, notification):
|
||||||
"""Close a single notification from this group"""
|
"""Close a single notification from this group with proper cache cleanup"""
|
||||||
try:
|
try:
|
||||||
cleanup_notification_specific_caches(
|
# Get notification ID for cache cleanup
|
||||||
app_icon_source=getattr(notification, "app_icon_source", None),
|
notification_id = getattr(notification._notification, "id", None)
|
||||||
notification_image_cache_key=getattr(
|
app_icon_source = getattr(notification._notification, "app_icon", None)
|
||||||
notification, "notification_image_cache_key", None
|
|
||||||
),
|
# Clean up caches using notification ID pattern
|
||||||
)
|
if notification_id:
|
||||||
|
cleanup_notification_specific_caches(
|
||||||
|
app_icon_source=app_icon_source,
|
||||||
|
notification_image_cache_key=f"notif_{notification_id}_*"
|
||||||
|
)
|
||||||
|
logger.debug(f"Cleaned up caches for notification ID: {notification_id}")
|
||||||
|
|
||||||
notification_service.remove_cached_notification(notification.cache_id)
|
notification_service.remove_cached_notification(notification.cache_id)
|
||||||
logger.debug(f"Closed single notification: {notification.cache_id}")
|
logger.debug(f"Closed single notification: {notification.cache_id}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -567,17 +580,18 @@ class NotificationCenterWidget(NotificationWidget):
|
|||||||
|
|
||||||
def _on_close_clicked(self, *args):
|
def _on_close_clicked(self, *args):
|
||||||
try:
|
try:
|
||||||
# Clean up this notification's cached icons AND images
|
# Get notification ID for cache cleanup
|
||||||
cleanup_notification_specific_caches(
|
notification_id = getattr(self.notification, "id", None)
|
||||||
app_icon_source=getattr(self, "app_icon_source", None),
|
app_icon_source = getattr(self.notification, "app_icon", None)
|
||||||
notification_image_cache_key=getattr(
|
|
||||||
self, "notification_image_cache_key", None
|
# Clean up caches using notification ID pattern
|
||||||
),
|
if notification_id:
|
||||||
)
|
cleanup_notification_specific_caches(
|
||||||
logger.debug(
|
app_icon_source=app_icon_source,
|
||||||
f"Cleaned up all caches for notification center: {self.notification_id}"
|
notification_image_cache_key=f"notif_{notification_id}_*"
|
||||||
)
|
)
|
||||||
|
logger.debug(f"Cleaned up caches for notification center ID: {notification_id}")
|
||||||
|
|
||||||
notification_service.remove_cached_notification(self.notification_id)
|
notification_service.remove_cached_notification(self.notification_id)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error removing notification {self.notification_id}: {e}")
|
logger.error(f"Error removing notification {self.notification_id}: {e}")
|
||||||
|
|||||||
Reference in new issue
Block a user