aboutsummaryrefslogtreecommitdiff
path: root/src-vue/src/plugins
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2023-02-14 00:00:47 +0100
committerGitHub <noreply@github.com>2023-02-14 00:00:47 +0100
commit2bdc60266adc1920a31488309657dd8db13b33f0 (patch)
tree9c8c73cdcc4fa97a0688af8f192a1e871f2a8c8d /src-vue/src/plugins
parentcb638c556594a996c94f501fcbd009984a63fd55 (diff)
downloadFlightCore-2bdc60266adc1920a31488309657dd8db13b33f0.tar.gz
FlightCore-2bdc60266adc1920a31488309657dd8db13b33f0.zip
refactor: Get TS package API response from backend (#168)
* refactor: Get TS package API response from backend Previously Thunderstore package index was done in frontend. Should be moved to backend instead as backend is reponsible for such tasks while frontend should just be used to store and display information. * refactor: Filter TS API response in backend * refactor: Rename function Makes it more descriptive what it does * refactor: Use gen. binds instead of duped struct Replaces the current TypeScript interface defintions with autogenerated bindings. * fix: Properly type variable * fix: Correct imported path of interface file * fix: Update struct field types to fix typing issue i32 should be big enough unless Thunderstore and Northstar suddenly becomes really huge and we start seeing over 4 million downloads on some mod * fix: Correct imported path of interface file
Diffstat (limited to 'src-vue/src/plugins')
-rw-r--r--src-vue/src/plugins/store.ts22
1 files changed, 15 insertions, 7 deletions
diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts
index d4371fb8..e44b1c3f 100644
--- a/src-vue/src/plugins/store.ts
+++ b/src-vue/src/plugins/store.ts
@@ -13,7 +13,7 @@ import { open } from '@tauri-apps/api/dialog';
import { Store } from 'tauri-plugin-store-api';
import { router } from "../main";
import { ReleaseInfo } from "../../../src-tauri/bindings/ReleaseInfo";
-import { ThunderstoreMod } from '../utils/thunderstore/ThunderstoreMod';
+import { ThunderstoreMod } from "../../../src-tauri/bindings/ThunderstoreMod";
import { NorthstarMod } from "../../../src-tauri/bindings/NorthstarMod";
import { searchModule } from './modules/search';
@@ -242,14 +242,22 @@ export const store = createStore<FlightCoreStore>({
await store.commit('loadInstalledMods');
if (state.thunderstoreMods.length !== 0) return;
- const response = await fetch('https://northstar.thunderstore.io/api/v1/package/');
- let mods = JSON.parse(await (await response.blob()).text());
+ let mods: ThunderstoreMod[] = [];
+ await invoke<ThunderstoreMod[]>("query_thunderstore_packages_api")
+ .then((message) => {
+ mods = message;
+ })
+ .catch((error) => {
+ console.error(error);
+ return;
+ });
+
+ if (mods == undefined) {
+ return;
+ }
// Remove some mods from listing
- const removedMods = ['Northstar', 'NorthstarReleaseCandidate', 'r2modman'];
- state.thunderstoreMods = mods.filter((mod: ThunderstoreMod) => {
- return !removedMods.includes(mod.name) && !mod.is_deprecated;
- });
+ state.thunderstoreMods = mods;
// Retrieve categories from mods
state.thunderstoreModsCategories = mods