refactor: reactify

This commit is contained in:
Szedann 2025-07-23 21:12:51 +02:00
parent 06aea54d6d
commit 8a1645554e
2 changed files with 10 additions and 7 deletions

View file

@ -1,6 +1,7 @@
import type { ClusterModel, GameLoader, ManagedPackage, ManagedVersion, Paginated, Provider, SearchQuery, SearchResult } from '@/bindings.gen';
import type { BindingCommands } from '@/types/global';
import type { UndefinedInitialDataOptions } from '@tanstack/react-query';
import type { Dispatch, SetStateAction } from 'react';
import { bindings } from '@/main';
import { PROVIDERS } from '@/utils';
import { useCommand } from '@onelauncher/common';
@ -9,11 +10,11 @@ import { createContext, useContext, useEffect, useMemo, useState } from 'react';
export interface BrowserControllerType {
cluster: ClusterModel | undefined;
setCluster: (cluster: ClusterModel | undefined) => void;
setCluster: Dispatch<SetStateAction<ClusterModel | undefined>>;
provider: Provider;
setProvider: (provider: Provider) => void;
setProvider: Dispatch<SetStateAction<Provider>>;
query: SearchQuery;
setQuery: (query: SearchQuery) => void;
setQuery: Dispatch<SetStateAction<SearchQuery>>;
search: () => void;
}

View file

@ -71,14 +71,16 @@ function BrowserSidebar() {
<div className="flex flex-col gap-y-1">
<h6 className="my-1 uppercase opacity-60">Active Cluster</h6>
<Dropdown
onSelectionChange={(id) => {
const cluster = clusters?.find(item => item.id.toString() === id);
onSelectionChange={(index) => {
if (!clusters)
return;
const cluster = clusters[index as number];
context.setCluster(cluster);
}}
selectedKey={context.cluster?.id.toString()}
>
{clusters?.map(cluster => (
<Dropdown.Item id={cluster.id.toString()} key={cluster.id}>
{clusters?.map((cluster, index) => (
<Dropdown.Item id={index} key={cluster.id}>
{cluster.name}
</Dropdown.Item>
))}