From 4f2c3eb88c425f20a0d0f946872ab0f7cafb0ade Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sun, 2 Aug 2026 13:37:10 +0545 Subject: [PATCH] refactor(spotlight): use shared app cache --- src/window/spotlight/plugins/application.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/window/spotlight/plugins/application.py b/src/window/spotlight/plugins/application.py index 04bf0b5..9af0f14 100644 --- a/src/window/spotlight/plugins/application.py +++ b/src/window/spotlight/plugins/application.py @@ -1,10 +1,10 @@ import os from typing import Any -from fabric.utils import DesktopApp, get_desktop_applications, logger +from fabric.utils import DesktopApp, logger from gi.repository import Gio -from utils.functions import fuzzy_score +from utils.functions import fuzzy_score, get_desktop_apps, invalidate_desktop_apps_cache from window.spotlight.api import SearchResult, SpotlightPlugin @@ -49,7 +49,7 @@ class ApplicationPlugin(SpotlightPlugin): self._monitors: list[Gio.FileMonitor] = [] def initialize(self) -> None: - self._desktop_apps = get_desktop_applications() + self._desktop_apps = get_desktop_apps() self._dirty = False self._start_watching() @@ -70,6 +70,7 @@ class ApplicationPlugin(SpotlightPlugin): Gio.FileMonitorEvent.MOVED_IN, Gio.FileMonitorEvent.MOVED_OUT, ): + invalidate_desktop_apps_cache() self._dirty = True def cleanup(self) -> None: @@ -84,12 +85,10 @@ class ApplicationPlugin(SpotlightPlugin): if self._dirty: try: - self._desktop_apps = get_desktop_applications() + self._desktop_apps = get_desktop_apps() self._dirty = False except Exception as e: - logger.warning( - f"[application] self._desktop_apps = get_desktop_applications() failed: {e}" - ) + logger.warning(f"[application] get_desktop_apps() failed: {e}") results: list[SearchResult] = [] for app in self._desktop_apps: