From 34d1a34b10f4386865f3c241c5ae4026d2bfd8bd Mon Sep 17 00:00:00 2001
From: AAGaming <aa@mail.catvibers.me>
Date: Sat, 5 Aug 2023 01:11:43 -0400
Subject: Migrate most of frontend callServerMethod usage over to websocket

---
 frontend/src/store.tsx | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

(limited to 'frontend/src/store.tsx')

diff --git a/frontend/src/store.tsx b/frontend/src/store.tsx
index bc419430..5ae98ec4 100644
--- a/frontend/src/store.tsx
+++ b/frontend/src/store.tsx
@@ -1,4 +1,4 @@
-import { InstallType, Plugin } from './plugin';
+import { InstallType, Plugin, installPlugin, installPlugins } from './plugin';
 import { getSetting, setSetting } from './utils/settings';
 
 export enum Store {
@@ -92,33 +92,24 @@ export async function getPluginList(): Promise<StorePlugin[]> {
 
 export async function installFromURL(url: string) {
   const splitURL = url.split('/');
-  await window.DeckyPluginLoader.callServerMethod('install_plugin', {
-    name: splitURL[splitURL.length - 1].replace('.zip', ''),
-    artifact: url,
-  });
+  await installPlugin(url, splitURL[splitURL.length - 1].replace('.zip', ''));
 }
 
 export async function requestPluginInstall(plugin: string, selectedVer: StorePluginVersion, installType: InstallType) {
   const artifactUrl = selectedVer.artifact ?? pluginUrl(selectedVer.hash);
-  await window.DeckyPluginLoader.callServerMethod('install_plugin', {
-    name: plugin,
-    artifact: artifactUrl,
-    version: selectedVer.name,
-    hash: selectedVer.hash,
-    install_type: installType,
-  });
+  await installPlugin(artifactUrl, plugin, selectedVer.name, selectedVer.hash, installType);
 }
 
 export async function requestMultiplePluginInstalls(requests: PluginInstallRequest[]) {
-  await window.DeckyPluginLoader.callServerMethod('install_plugins', {
-    requests: requests.map(({ plugin, installType, selectedVer }) => ({
+  await installPlugins(
+    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> {
-- 
cgit v1.2.3

