summaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
Diffstat (limited to 'frontend')
-rw-r--r--frontend/src/components/settings/pages/general/Updater.tsx64
-rw-r--r--frontend/src/plugin-loader.tsx11
-rw-r--r--frontend/src/store.tsx47
3 files changed, 42 insertions, 80 deletions
diff --git a/frontend/src/components/settings/pages/general/Updater.tsx b/frontend/src/components/settings/pages/general/Updater.tsx
index cb58b24c..9635162c 100644
--- a/frontend/src/components/settings/pages/general/Updater.tsx
+++ b/frontend/src/components/settings/pages/general/Updater.tsx
@@ -17,46 +17,38 @@ function PatchNotesModal({ versionInfo, closeModal }: { versionInfo: VerInfo | n
return (
<Focusable onCancelButton={closeModal}>
<Carousel
- fnItemRenderer={(id: number, ...args: any[]) => {
- console.log(args, versionInfo);
- return (
- <Focusable
- onActivate={() => {}}
- style={{
- marginTop: '40px',
- height: 'calc( 100% - 40px )',
- overflowY: 'scroll',
- display: 'flex',
- justifyContent: 'center',
- margin: '40px',
- }}
- >
- <div>
- <h1>{versionInfo?.all?.[id]?.name}</h1>
- {versionInfo?.all?.[id]?.body ? (
- <Suspense fallback={<Spinner style={{ width: '24', height: '24' }} />}>
- <MarkdownRenderer>{versionInfo.all[id].body}</MarkdownRenderer>
- </Suspense>
- ) : (
- 'no patch notes for this version'
- )}
- </div>
- </Focusable>
- );
- }}
- fnGetId={(id) => {
- return id;
- }}
+ fnItemRenderer={(id: number) => (
+ <Focusable
+ onActivate={() => {}}
+ style={{
+ marginTop: '40px',
+ height: 'calc( 100% - 40px )',
+ overflowY: 'scroll',
+ display: 'flex',
+ justifyContent: 'center',
+ margin: '40px',
+ }}
+ >
+ <div>
+ <h1>{versionInfo?.all?.[id]?.name}</h1>
+ {versionInfo?.all?.[id]?.body ? (
+ <Suspense fallback={<Spinner style={{ width: '24', height: '24' }} />}>
+ <MarkdownRenderer>{versionInfo.all[id].body}</MarkdownRenderer>
+ </Suspense>
+ ) : (
+ 'no patch notes for this version'
+ )}
+ </div>
+ </Focusable>
+ )}
+ fnGetId={(id) => id}
nNumItems={versionInfo?.all?.length}
nHeight={window.innerHeight - 150}
nItemHeight={window.innerHeight - 200}
nItemMarginX={0}
initialColumn={0}
autoFocus={true}
- fnGetColumnWidth={(...args: any[]) => {
- console.log('cw', args);
- return window.innerWidth;
- }}
+ fnGetColumnWidth={() => window.innerWidth}
/>
</Focusable>
);
@@ -98,8 +90,8 @@ export default function UpdaterSettings() {
return (
<>
<Field
- onOptionsActionDescription="Patch Notes"
- onOptionsButton={showPatchNotes}
+ onOptionsActionDescription={versionInfo?.all ? 'Patch Notes' : undefined}
+ onOptionsButton={versionInfo?.all ? showPatchNotes : undefined}
label="Updates"
description={
versionInfo && (
diff --git a/frontend/src/plugin-loader.tsx b/frontend/src/plugin-loader.tsx
index 661a2f67..85b03704 100644
--- a/frontend/src/plugin-loader.tsx
+++ b/frontend/src/plugin-loader.tsx
@@ -150,16 +150,7 @@ class PluginLoader extends Logger {
showModal(
<ModalRoot
onOK={async () => {
- const formData = new FormData();
- formData.append('name', name);
- await fetch('http://localhost:1337/browser/uninstall_plugin', {
- method: 'POST',
- body: formData,
- credentials: 'include',
- headers: {
- Authentication: window.deckyAuthToken,
- },
- });
+ await this.callServerMethod('uninstall_plugin', { name });
}}
onCancel={() => {
// do nothing
diff --git a/frontend/src/store.tsx b/frontend/src/store.tsx
index 3e9d6823..12c8972d 100644
--- a/frontend/src/store.tsx
+++ b/frontend/src/store.tsx
@@ -42,17 +42,10 @@ export function getLegacyPluginList(): Promise<LegacyStorePlugin[]> {
}
export async function installFromURL(url: string) {
- const formData = new FormData();
const splitURL = url.split('/');
- formData.append('name', splitURL[splitURL.length - 1].replace('.zip', ''));
- formData.append('artifact', url);
- await fetch('http://localhost:1337/browser/install_plugin', {
- method: 'POST',
- body: formData,
- credentials: 'include',
- headers: {
- Authentication: window.deckyAuthToken,
- },
+ await window.DeckyPluginLoader.callServerMethod('install_plugin', {
+ name: splitURL[splitURL.length - 1].replace('.zip', ''),
+ artifact: url,
});
}
@@ -60,18 +53,11 @@ export function requestLegacyPluginInstall(plugin: LegacyStorePlugin, selectedVe
showModal(
<ModalRoot
onOK={() => {
- const formData = new FormData();
- formData.append('name', plugin.artifact);
- formData.append('artifact', `https://github.com/${plugin.artifact}/archive/refs/tags/${selectedVer}.zip`);
- formData.append('version', selectedVer);
- formData.append('hash', plugin.versions[selectedVer]);
- fetch('http://localhost:1337/browser/install_plugin', {
- method: 'POST',
- body: formData,
- credentials: 'include',
- headers: {
- Authentication: window.deckyAuthToken,
- },
+ window.DeckyPluginLoader.callServerMethod('install_plugin', {
+ name: plugin.artifact,
+ artifact: `https://github.com/${plugin.artifact}/archive/refs/tags/${selectedVer}.zip`,
+ version: selectedVer,
+ hash: plugin.versions[selectedVer],
});
}}
onCancel={() => {
@@ -89,18 +75,11 @@ export function requestLegacyPluginInstall(plugin: LegacyStorePlugin, selectedVe
}
export async function requestPluginInstall(plugin: string, selectedVer: StorePluginVersion) {
- const formData = new FormData();
- formData.append('name', plugin);
- formData.append('artifact', `https://cdn.tzatzikiweeb.moe/file/steam-deck-homebrew/versions/${selectedVer.hash}.zip`);
- formData.append('version', selectedVer.name);
- formData.append('hash', selectedVer.hash);
- await fetch('http://localhost:1337/browser/install_plugin', {
- method: 'POST',
- body: formData,
- credentials: 'include',
- headers: {
- Authentication: window.deckyAuthToken,
- },
+ await window.DeckyPluginLoader.callServerMethod('install_plugin', {
+ name: plugin,
+ artifact: `https://cdn.tzatzikiweeb.moe/file/steam-deck-homebrew/versions/${selectedVer.hash}.zip`,
+ version: selectedVer.name,
+ hash: selectedVer.hash,
});
}