mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-05-01 13:03:01 +00:00
fix(plugins): use cached store on HTMX re-swap; reserve searchPluginStore(true) for first load
searchPluginStore(true) bypasses the isCacheValid check unconditionally, so every tab revisit was hitting the GitHub commit-info API even within the 5-minute cache window. Set window.pluginManager._reswap = true in the htmx:afterSwap handler and read it in initializePlugins() to call searchPluginStore(false) on re-swaps (respects the 5-minute cache) vs searchPluginStore(true) on first load (always fetches fresh). Explicit user refresh via refreshPlugins() already calls searchPluginStore(true) directly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1168,6 +1168,7 @@ function initializePluginPageWhenReady() {
|
||||
// Reset all initialization flags so the fresh empty DOM gets populated
|
||||
window.pluginManager.initialized = false;
|
||||
window.pluginManager.initializing = false;
|
||||
window.pluginManager._reswap = true; // signal: use cached store, don't re-fetch GitHub
|
||||
pluginsInitialized = false;
|
||||
initTimer = setTimeout(attemptInit, 100);
|
||||
}
|
||||
@@ -1212,9 +1213,13 @@ function initializePlugins() {
|
||||
console.warn('[INIT] checkGitHubAuthStatus not available yet');
|
||||
}
|
||||
|
||||
// Load both installed plugins and plugin store
|
||||
// Load both installed plugins and plugin store.
|
||||
// On HTMX re-swaps use cached store data (fetchCommitInfo=false) to avoid
|
||||
// re-hitting GitHub on every tab switch; only fetch fresh on first load.
|
||||
const isReswap = !!window.pluginManager._reswap;
|
||||
window.pluginManager._reswap = false;
|
||||
loadInstalledPlugins();
|
||||
searchPluginStore(true); // Load plugin store with fresh metadata from GitHub
|
||||
searchPluginStore(!isReswap);
|
||||
|
||||
// Setup search functionality (with guard against duplicate listeners)
|
||||
const searchInput = document.getElementById('plugin-search');
|
||||
|
||||
Reference in New Issue
Block a user