ChemPal Documentation - v1.6.0
    Preparing search index...

    Function clearSearchResults

    • Clears all persisted search results from IndexedDB. By default this dispatches IDB_SEARCH_RESULTS_CLEARED so listeners (e.g. the App) can react to an explicit, user-initiated clear. Pass { notify: false } to clear silently — used when resetting the store at the start of a new search, where firing the event would bounce the user off the results panel.

      Parameters

      Returns Promise<void>

      await clearSearchResults();                  // clears + notifies listeners
      await clearSearchResults({ notify: false }); // clears silently
      export async function clearSearchResults(options: { notify?: boolean } = {}): Promise<void> {
      const { notify = true } = options;
      try {
      const db = await getDB();
      await db.delete(IDB_STORE.SEARCH_RESULTS, 'current');
      if (notify) {
      emitSearchResultsCleared();
      }
      } catch (error) {
      logger.error('Failed to clear search results from IndexedDB', { error });
      }
      }