Add update all button to plugin list (#466)

This commit is contained in:
Jonas Dellinger
2023-05-29 18:29:36 +02:00
committed by GitHub
parent 5114bb5711
commit 010feddf36
7 changed files with 215 additions and 19 deletions
+23 -2
View File
@@ -23,6 +23,12 @@ export interface StorePlugin {
image_url: string;
}
export interface PluginInstallRequest {
plugin: string;
selectedVer: StorePluginVersion;
installType: InstallType;
}
// name: version
export type PluginUpdateMapping = Map<string, StorePluginVersion>;
@@ -74,8 +80,7 @@ export async function installFromURL(url: string) {
}
export async function requestPluginInstall(plugin: string, selectedVer: StorePluginVersion, installType: InstallType) {
const artifactUrl =
selectedVer.artifact ?? `https://cdn.tzatzikiweeb.moe/file/steam-deck-homebrew/versions/${selectedVer.hash}.zip`;
const artifactUrl = selectedVer.artifact ?? pluginUrl(selectedVer.hash);
await window.DeckyPluginLoader.callServerMethod('install_plugin', {
name: plugin,
artifact: artifactUrl,
@@ -85,6 +90,18 @@ export async function requestPluginInstall(plugin: string, selectedVer: StorePlu
});
}
export async function requestMultiplePluginInstalls(requests: PluginInstallRequest[]) {
await window.DeckyPluginLoader.callServerMethod('install_plugins', {
requests: requests.map(({ plugin, installType, selectedVer }) => ({
name: plugin,
artifact: selectedVer.artifact ?? pluginUrl(selectedVer.hash),
version: selectedVer.name,
hash: selectedVer.hash,
install_type: installType,
})),
});
}
export async function checkForUpdates(plugins: Plugin[]): Promise<PluginUpdateMapping> {
const serverData = await getPluginList();
const updateMap = new Map<string, StorePluginVersion>();
@@ -96,3 +113,7 @@ export async function checkForUpdates(plugins: Plugin[]): Promise<PluginUpdateMa
}
return updateMap;
}
function pluginUrl(hash: string) {
return `https://cdn.tzatzikiweeb.moe/file/steam-deck-homebrew/versions/${hash}.zip`;
}