-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Freeze updates for devs (#582)
- Loading branch information
Showing
9 changed files
with
117 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 19 additions & 3 deletions
22
frontend/src/components/settings/pages/plugin_list/PluginListLabel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { DeckyState } from './components/DeckyState'; | ||
import { PluginUpdateMapping } from './store'; | ||
import { getSetting, setSetting } from './utils/settings'; | ||
|
||
/** | ||
* A Service class for managing the state and actions related to the frozen plugins feature. | ||
* | ||
* It's mostly responsible for sending setting updates to the server and keeping the local state in sync. | ||
*/ | ||
export class FrozenPluginService { | ||
constructor(private deckyState: DeckyState) {} | ||
|
||
init() { | ||
getSetting<string[]>('frozenPlugins', []).then((frozenPlugins) => { | ||
this.deckyState.setFrozenPlugins(frozenPlugins); | ||
}); | ||
} | ||
|
||
/** | ||
* Sends the new frozen plugins list to the server and persists it locally in the decky state | ||
* | ||
* @param frozenPlugins The new list of frozen plugins | ||
*/ | ||
async update(frozenPlugins: string[]) { | ||
await setSetting('frozenPlugins', frozenPlugins); | ||
this.deckyState.setFrozenPlugins(frozenPlugins); | ||
|
||
// Remove pending updates for frozen plugins | ||
const updates = this.deckyState.publicState().updates; | ||
|
||
if (updates) { | ||
const filteredUpdates = new Map() as PluginUpdateMapping; | ||
updates.forEach((v, k) => { | ||
if (!frozenPlugins.includes(k)) { | ||
filteredUpdates.set(k, v); | ||
} | ||
}); | ||
|
||
this.deckyState.setUpdates(filteredUpdates); | ||
} | ||
} | ||
|
||
/** | ||
* Refreshes the state of frozen plugins in the local state | ||
*/ | ||
async invalidate() { | ||
this.deckyState.setFrozenPlugins(await getSetting('frozenPlugins', [])); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters