diff --git a/Cargo.lock b/Cargo.lock index aa81e66..654a9b3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3336,6 +3336,12 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "murmur2" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb585ade2549a017db2e35978b77c319214fa4b37cede841e27954dd6e8f3ca8" + [[package]] name = "ndk" version = "0.9.0" @@ -3813,6 +3819,7 @@ dependencies = [ "interpulse", "iota_stronghold", "lazy_static", + "murmur2", "notify", "notify-debouncer-mini", "onelauncher_gamemode", diff --git a/Cargo.toml b/Cargo.toml index 8e62c8b..d4a2c25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -133,6 +133,7 @@ async-compression = { version = "0.4.12", features = [ "flate2", "tokio" ] } flate2 = { version = "1.0" } sha1_smol = { version = "1.0", features = [ "std" ] } sha2 = { version = "0.10" } +murmur2 = { version = "0.1.0" } bytes = { version = "1.7" } # # ============= UTILITY ============= # # diff --git a/apps/desktop/src/api/commands/package.rs b/apps/desktop/src/api/commands/package.rs index f59967a..40690bb 100644 --- a/apps/desktop/src/api/commands/package.rs +++ b/apps/desktop/src/api/commands/package.rs @@ -213,7 +213,8 @@ pub async fn sync_cluster_packages(cluster_path: ClusterPath) -> Result<(), Stri pub async fn sync_cluster_packages_by_type( cluster_path: ClusterPath, package_type: PackageType, + clear: Option, ) -> Result<(), String> { - package::sync_packages_by_type(&cluster_path, package_type).await?; + package::sync_packages_by_type(&cluster_path, package_type, clear).await?; Ok(()) } diff --git a/apps/frontend/src/ui/pages/cluster/ClusterMods.tsx b/apps/frontend/src/ui/pages/cluster/ClusterMods.tsx index 66b4c72..38361a6 100644 --- a/apps/frontend/src/ui/pages/cluster/ClusterMods.tsx +++ b/apps/frontend/src/ui/pages/cluster/ClusterMods.tsx @@ -1,6 +1,6 @@ -import type { ManagedPackage, Package, Providers } from '@onelauncher/client/bindings'; +import type { Package } from '@onelauncher/client/bindings'; import UFuzzy from '@leeoniya/ufuzzy'; -import { FilterFunnel01Icon, SearchMdIcon, Trash03Icon } from '@untitled-theme/icons-solid'; +import { FilterFunnel01Icon, RefreshCw01Icon, SearchMdIcon, Trash03Icon } from '@untitled-theme/icons-solid'; import { bridge } from '~imports'; import Button from '~ui/components/base/Button'; import TextField from '~ui/components/base/TextField'; @@ -8,39 +8,13 @@ import ScrollableContainer from '~ui/components/ScrollableContainer'; import Sidebar from '~ui/components/Sidebar'; import useBrowser from '~ui/hooks/useBrowser'; import useClusterContext from '~ui/hooks/useCluster'; -import useCommand, { tryResult } from '~ui/hooks/useCommand'; -import { createEffect, createResource, createSignal, For, Match, Show, Switch } from 'solid-js'; +import useCommand from '~ui/hooks/useCommand'; +import { createEffect, createSignal, For, Match, Show, Switch } from 'solid-js'; -// TODO: Possibly optimise this as it has 2 cloned lists, and another containing only the names +// TODO: This needs a rewrite. function ClusterMods() { const [cluster] = useClusterContext(); - const [mods, { refetch }] = useCommand(cluster, () => bridge.commands.getClusterPackages(cluster()?.path || '', 'mod')); - const [managedMods] = createResource(mods, async () => { - const list = mods(); - if (!list) - return Promise.resolve(new Map()); - - const providers: Map = new Map(); - - list.forEach((mod) => { - if (mod.meta.type === 'managed') - providers.set(mod.meta.provider, [ - ...(providers.get(mod.meta.provider) || []), - mod.meta.package_id, - ]); - }); - - const formatted: Map = new Map(); - - for (const [provider, packageIds] of providers.entries()) { - const result = await tryResult(() => bridge.commands.getProviderPackages(provider, packageIds)); - formatted.set(provider, result); - } - - return formatted; - }, { - initialValue: new Map(), - }); + const [mods, { refetch: refetchMods }] = useCommand(cluster, () => bridge.commands.getClusterPackages(cluster()?.path || '', 'mod')); // Mods to display, should be a clone of the mods array but sorted const [displayedMods, setDisplayedMods] = createSignal([]); @@ -101,7 +75,15 @@ function ClusterMods() {

Mods

-
+
+