summaryrefslogtreecommitdiff
path: root/frontend/src/store.tsx
diff options
context:
space:
mode:
authorParty Wumpus <48649272+PartyWumpus@users.noreply.github.com>2024-02-07 17:38:08 +0000
committerAAGaming <aagaming@riseup.net>2024-02-14 16:43:30 -0500
commitec41c6121956afc4eb33c9f21905cdce4c07a097 (patch)
tree6310daec76d70fbbd78fb765b36adf2b0fde1ce5 /frontend/src/store.tsx
parent21c7742f9a5ad499a95c6b54644d5494d5536967 (diff)
downloaddecky-loader-ec41c6121956afc4eb33c9f21905cdce4c07a097.tar.gz
decky-loader-ec41c6121956afc4eb33c9f21905cdce4c07a097.zip
Refactor plugin store and add sorting by downloads and release date (#547)
* untested first commit * fix types & names * comment out built in sorting for now * rerun search when sort changes * fix ts complaints * use prettier * stop switch-case fall through * move spinner * use locale instead of hardcoded string * fix typo * add sorting by downloads & try using the data field in the dropdown for data * fix typing error * fix asc/desc in dropdown * fix asc/desc again. asc = smaller one go first aaaaa * I don't think i know what ascending means maybe * use props instead of children, like a normal component
Diffstat (limited to 'frontend/src/store.tsx')
-rw-r--r--frontend/src/store.tsx26
1 files changed, 23 insertions, 3 deletions
diff --git a/frontend/src/store.tsx b/frontend/src/store.tsx
index 3fcfdb2f..8ab8f50a 100644
--- a/frontend/src/store.tsx
+++ b/frontend/src/store.tsx
@@ -7,6 +7,17 @@ export enum Store {
Custom,
}
+export enum SortOptions {
+ name = 'name',
+ date = 'date',
+ downloads = 'downloads',
+}
+
+export enum SortDirections {
+ ascending = 'asc',
+ descending = 'desc',
+}
+
export interface StorePluginVersion {
name: string;
hash: string;
@@ -36,10 +47,19 @@ export async function getStore(): Promise<Store> {
return await getSetting<Store>('store', Store.Default);
}
-export async function getPluginList(): Promise<StorePlugin[]> {
- let version = await DeckyPluginLoader.updateVersion();
+export async function getPluginList(
+ sort_by: SortOptions | null = null,
+ sort_direction: SortDirections | null = null,
+): Promise<StorePlugin[]> {
+ let version = await window.DeckyPluginLoader.updateVersion();
let store = await getSetting<Store | null>('store', null);
let customURL = await getSetting<string>('store-url', 'https://plugins.deckbrew.xyz/plugins');
+
+ let query: URLSearchParams | string = new URLSearchParams();
+ sort_by && query.set('sort_by', sort_by);
+ sort_direction && query.set('sort_direction', sort_direction);
+ query = '?' + String(query);
+
let storeURL;
if (store === null) {
console.log('Could not get store, using Default.');
@@ -82,7 +102,7 @@ export async function getPluginList(): Promise<StorePlugin[]> {
storeURL = 'https://plugins.deckbrew.xyz/plugins';
break;
}
- return fetch(storeURL, {
+ return fetch(storeURL + query, {
method: 'GET',
headers: {
'X-Decky-Version': version.current,