Add functionality to hide plugins from quick access menu (#468)

This commit is contained in:
Jonas Dellinger
2023-06-07 07:35:05 +02:00
committed by GitHub
parent 1c6270ccd6
commit 47bc910a84
14 changed files with 301 additions and 57 deletions
+34
View File
@@ -0,0 +1,34 @@
import { DeckyState } from './components/DeckyState';
import { getSetting, setSetting } from './utils/settings';
/**
* A Service class for managing the state and actions related to the hidden plugins feature
*
* It's mostly responsible for sending setting updates to the server and keeping the local state in sync.
*/
export class HiddenPluginsService {
constructor(private deckyState: DeckyState) {}
init() {
getSetting<string[]>('hiddenPlugins', []).then((hiddenPlugins) => {
this.deckyState.setHiddenPlugins(hiddenPlugins);
});
}
/**
* Sends the new hidden plugins list to the server and persists it locally in the decky state
*
* @param hiddenPlugins The new list of hidden plugins
*/
async update(hiddenPlugins: string[]) {
await setSetting('hiddenPlugins', hiddenPlugins);
this.deckyState.setHiddenPlugins(hiddenPlugins);
}
/**
* Refreshes the state of hidden plugins in the local state
*/
async invalidate() {
this.deckyState.setHiddenPlugins(await getSetting('hiddenPlugins', []));
}
}