mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-10-01 03:36:04 +08:00
fix: avoid userpreferences PUT flood from SideNav refresh trigger (#1119)
kickSideNav toggled a dummy favorite via addFavorite/removeFavorite, which persist through prefs/set and issue a PUT /v1/userpreferences on every toggle, flooding the backend and surfacing 500 errors. Switch to the in-memory prefs/load mutation so the SideNav still re-renders without any network request. Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { FAVORITE_TYPES } from '@shell/store/prefs';
|
||||
|
||||
/**
|
||||
* Dynamically toggles SideNav entries based on the enabled status of a specific Addon.
|
||||
*
|
||||
@@ -26,10 +28,13 @@ export function registerAddonSideNav(store, productName, {
|
||||
|
||||
// Toggle the trigger a few times so an early kick (fired before the SideNav
|
||||
// has mounted on first login) is retried once the component is listening.
|
||||
// Use the prefs/load mutation (in-memory only)
|
||||
[0, 600, 1500].forEach((delay) => {
|
||||
setTimeout(() => {
|
||||
store.dispatch('type-map/addFavorite', TRIGGER);
|
||||
setTimeout(() => store.dispatch('type-map/removeFavorite', TRIGGER), 300);
|
||||
const base = (store.getters['prefs/get'](FAVORITE_TYPES) || []).filter((t) => t !== TRIGGER);
|
||||
|
||||
store.commit('prefs/load', { key: FAVORITE_TYPES, value: [...base, TRIGGER] });
|
||||
setTimeout(() => store.commit('prefs/load', { key: FAVORITE_TYPES, value: [...base] }), 300);
|
||||
}, delay);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user