Skip to content

Commit bf1ce4d

Browse files
committed
Filters instances shown for mods
1 parent 0b4433e commit bf1ce4d

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

apps/desktop/packages/mainWindow/src/components/ModDownloadButton/hooks/useInstanceSearch.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import { createSignal, createMemo, createEffect } from "solid-js"
22
import { useGlobalStore } from "@/components/GlobalStoreContext"
33
import { getInstanceImageUrl } from "@/utils/instances"
44

5-
export const useInstanceSearch = () => {
5+
interface UseInstanceSearchOptions {
6+
addonType?: string
7+
}
8+
9+
export const useInstanceSearch = (options?: UseInstanceSearchOptions) => {
610
const [searchQuery, setSearchQuery] = createSignal("")
711
const [debouncedQuery, setDebouncedQuery] = createSignal("")
812
const [hoveredInstanceId, setHoveredInstanceId] = createSignal<number | null>(
@@ -38,6 +42,14 @@ export const useInstanceSearch = () => {
3842
: null
3943
}
4044
})
45+
.filter((instance) => {
46+
// For mods, only show instances with modloaders
47+
if (options?.addonType === "mod") {
48+
return instance.modloader !== "vanilla"
49+
}
50+
// For all other addon types, show all instances
51+
return true
52+
})
4153
})
4254

4355
const filteredInstances = createMemo(() => {

apps/desktop/packages/mainWindow/src/components/ModDownloadButton/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const ModDownloadButton = (props: ModDownloadButtonProps) => {
3838
setHoveredInstanceId,
3939
filteredInstances,
4040
shouldVirtualize
41-
} = useInstanceSearch()
41+
} = useInstanceSearch({ addonType: props.addon?.type })
4242

4343
const { loading, setLoading, progress, setProgress } = useTaskProgress(
4444
instanceTaskIds,

apps/desktop/packages/mainWindow/src/pages/Library/Instance/Tabs/Addons/components/AddonFilters.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ interface AddonFiltersProps {
2525
onOpenFolder: () => void
2626
onUpdateAll: () => void
2727
updateCount: () => number
28+
hasModloaders: () => boolean
2829
}
2930

3031
export const AddonFilters = (props: AddonFiltersProps) => {
@@ -34,6 +35,15 @@ export const AddonFilters = (props: AddonFiltersProps) => {
3435
return t(`instance.tabs.${type}`)
3536
}
3637

38+
const visibleAddonTypes = () => {
39+
return ADDON_TYPES.filter((type) => {
40+
if (type === "mods" && !props.hasModloaders()) {
41+
return false
42+
}
43+
return true
44+
})
45+
}
46+
3747
return (
3848
<div class="bg-darkSlate-800 border-darkSlate-700 sticky top-14 z-20 border-b px-6 py-4">
3949
<div class="flex flex-col gap-4">
@@ -102,7 +112,7 @@ export const AddonFilters = (props: AddonFiltersProps) => {
102112
<span class="text-lightSlate-600 text-sm">
103113
{t("instance.addon_types")}:
104114
</span>
105-
<For each={ADDON_TYPES}>
115+
<For each={visibleAddonTypes()}>
106116
{(type) => (
107117
<Badge
108118
variant={

apps/desktop/packages/mainWindow/src/pages/Library/Instance/Tabs/Addons/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ const Addons = () => {
3030
const isInstanceLocked = () =>
3131
!!routeData.instanceDetails.data?.modpack?.locked
3232

33+
const hasModloaders = () =>
34+
(routeData.instanceDetails.data?.modloaders?.length || 0) > 0
35+
3336
// Get selected rows reactively using row selection state
3437
const selectedRows = createMemo(() => {
3538
const rowSelectionState = addonData.rowSelection()
@@ -91,6 +94,7 @@ const Addons = () => {
9194
addonMutations.handleUpdateAll(addonData.filteredAddons())
9295
}
9396
updateCount={updateCount}
97+
hasModloaders={hasModloaders}
9498
/>
9599

96100
{/* Loading state */}

0 commit comments

Comments
 (0)