Skip to content

Commit

Permalink
Reimplemented invokes in the TypeScript side
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Nov 16, 2023
1 parent 1a33e92 commit 9feedba
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
7 changes: 4 additions & 3 deletions src/hooks/useSetlistData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ export const useSetlistData = (setlistData: SetlistData) => {
async () => {
if (state || !setlistData) return;

const exists = await invoke("version_exists_setlist", {
id: setlistData.id,
version: setlistData.version
const exists = await invoke("exists", {
appName: "official_setlist",
version: setlistData.version,
profile: setlistData.id
});

setState(exists ? SetlistStates.AVAILABLE : SetlistStates.NEW_UPDATE);
Expand Down
14 changes: 8 additions & 6 deletions src/hooks/useYARGVersion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ export const useYARGVersion = (releaseData: ExtendedReleaseData | undefined, pro
async () => {
if (state || !releaseData) return;

const exists = await invoke("version_exists_yarg", {
versionId: releaseData.tag_name,
const exists = await invoke("exists", {
appName: "yarg",
version: releaseData.tag_name,
profile: profileName
});

Expand All @@ -54,22 +55,23 @@ export const useYARGVersion = (releaseData: ExtendedReleaseData | undefined, pro
play: async () => {},
download: async () => {},
};
}
}

const play = async () => {
if (!releaseData) return;

setState(YARGStates.LOADING);

try {
await invoke("play_yarg", {
versionId: releaseData.tag_name,
await invoke("launch", {
appName: "yarg",
version: releaseData.tag_name,
profile: profileName
});

setState(YARGStates.PLAYING);

// As we don't have a way to check if the YARG game process is closed, we set a timer to avoid locking the state to PLAYING
// As we don't have a way to check if the YARG game process is closed, we set a timer to avoid locking the state to PLAYING
setTimeout(() => {
setState(YARGStates.AVAILABLE);
}, 10 * 1000);
Expand Down
8 changes: 5 additions & 3 deletions src/utils/Download/Processors/Setlist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ export class SetlistDownload extends BaseDownload implements IBaseDownload {
}

async start(): Promise<void> {
return await invoke("download_setlist", {
zipUrls: this.zipUrls,
id: this.id,
return await invoke("download_and_install", {
appName: "official_setlist",
version: this.version,
profile: this.id,
zipUrls: this.zipUrls,
sigUrls: [],
});
}

Expand Down
16 changes: 11 additions & 5 deletions src/utils/Download/Processors/YARG.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ export class YARGDownload extends BaseDownload implements IBaseDownload {
}

async start(): Promise<void> {
return await invoke("download_yarg", {
zipUrl: this.zipUrl,
sigUrl: this.sigUrl,
versionId: this.version,
profile: this.profile
let sigUrls: string[] = [];
if (this.sigUrl != null) {
sigUrls = [ this.sigUrl ];
}

return await invoke("download_and_install", {
appName: "yarg",
version: this.version,
profile: this.profile,
zipUrls: [ this.zipUrl ],
sigUrls: sigUrls,
});
}

Expand Down

0 comments on commit 9feedba

Please sign in to comment.