Skip to content

Commit c6ed32c

Browse files
committed
Improves UI and fixes deletion flow
1 parent e916358 commit c6ed32c

File tree

19 files changed

+215
-224
lines changed

19 files changed

+215
-224
lines changed

apps/desktop/packages/mainWindow/src/components/ModRow/Categories.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const Categories = (props: Props) => {
2121
<Tooltip>
2222
<TooltipTrigger>
2323
<Tag
24-
name={capitalize(String(categories()[0]))}
24+
name={capitalize(String(categories()[0])) ?? undefined}
2525
type="fixed"
2626
/>
2727
</TooltipTrigger>
@@ -39,7 +39,10 @@ const Categories = (props: Props) => {
3939
<div class="flex gap-2">
4040
<For each={categories().slice(1)}>
4141
{(category) => (
42-
<Tag name={capitalize(String(category))} type="fixed" />
42+
<Tag
43+
name={capitalize(String(category)) ?? undefined}
44+
type="fixed"
45+
/>
4346
)}
4447
</For>
4548
</div>
@@ -53,7 +56,10 @@ const Categories = (props: Props) => {
5356
{(category) => (
5457
<Tooltip>
5558
<TooltipTrigger>
56-
<Tag name={capitalize(String(category))} type="fixed" />
59+
<Tag
60+
name={capitalize(String(category)) ?? undefined}
61+
type="fixed"
62+
/>
5763
</TooltipTrigger>
5864
<TooltipContent>{capitalize(String(category))}</TooltipContent>
5965
</Tooltip>

apps/desktop/packages/mainWindow/src/components/NavSearchInputFilters.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ export function SearchModloaderDropdown(_props: DropdownProps) {
316316

317317
// Fast filtering
318318
return modloadersList.filter((modloader) =>
319-
modloader.label.toLowerCase().includes(query)
319+
modloader.label?.toLowerCase().includes(query)
320320
)
321321
})
322322

@@ -535,9 +535,7 @@ export function CurseforgeFiltersDropdown(_props: DropdownProps) {
535535
</DropdownMenuSubTrigger>
536536
<DropdownMenuPortal>
537537
<DropdownMenuSubContent>
538-
<DropdownMenuRadioGroup
539-
value={currentFilters().sort_field ?? ""}
540-
>
538+
<DropdownMenuRadioGroup value={currentFilters().sort_field ?? ""}>
541539
<For each={sortFieldOptions}>
542540
{(option) => (
543541
<DropdownMenuRadioItem
@@ -565,9 +563,7 @@ export function CurseforgeFiltersDropdown(_props: DropdownProps) {
565563
</DropdownMenuSubTrigger>
566564
<DropdownMenuPortal>
567565
<DropdownMenuSubContent>
568-
<DropdownMenuRadioGroup
569-
value={currentFilters().sort_order ?? ""}
570-
>
566+
<DropdownMenuRadioGroup value={currentFilters().sort_order ?? ""}>
571567
<For each={["ascending", "descending"] as const}>
572568
{(value) => (
573569
<DropdownMenuRadioItem
@@ -631,9 +627,7 @@ export function ModrinthFiltersDropdown(_props: DropdownProps) {
631627
</DropdownMenuSubTrigger>
632628
<DropdownMenuPortal>
633629
<DropdownMenuSubContent>
634-
<DropdownMenuRadioGroup
635-
value={currentFilters().sort_index ?? ""}
636-
>
630+
<DropdownMenuRadioGroup value={currentFilters().sort_index ?? ""}>
637631
<For each={sortOptions}>
638632
{(option) => (
639633
<DropdownMenuRadioItem
@@ -951,7 +945,7 @@ export function PlatformSpecificFilters(_props: DropdownProps) {
951945
src={selectedApi() === "curseforge" ? CurseforgeLogo : ModrinthLogo}
952946
class="h-4 w-4"
953947
/>
954-
{capitalize(selectedApi()!)} Filters
948+
{capitalize(selectedApi())} Filters
955949
</div>
956950
</DropdownMenuLabel>
957951
<DropdownMenuSeparator />

apps/desktop/packages/mainWindow/src/managers/ModalsManager/modals/ConfirmInstanceDeletion.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1-
import { rspc } from "@/utils/rspcClient"
1+
import { rspc, queryClient } from "@/utils/rspcClient"
22
import { ModalProps, useModal } from ".."
33
import ModalLayout from "../ModalLayout"
44
import { Button, toast } from "@gd/ui"
55
import { Trans, useTransContext } from "@gd/i18n"
6+
import { useGDNavigate } from "@/managers/NavigationManager"
67

78
const ConfirmInstanceDeletion = (props: ModalProps) => {
89
const [t] = useTransContext()
910
const modalsContext = useModal()
11+
const navigator = useGDNavigate()
1012

1113
const deleteInstanceMutation = rspc.createMutation(() => ({
1214
mutationKey: ["instance.deleteInstance"],
15+
onSuccess: async () => {
16+
// Cancel any ongoing queries for this instance to prevent errors
17+
await queryClient.cancelQueries({
18+
queryKey: ["instance.getInstanceDetails", props?.data?.id]
19+
})
20+
await queryClient.cancelQueries({
21+
queryKey: ["instance.getModpackInfo", props?.data?.id]
22+
})
23+
await queryClient.cancelQueries({
24+
queryKey: ["instance.getInstanceMods", props?.data?.id]
25+
})
26+
27+
navigator.navigate("/library")
28+
},
1329
onError: (error) => {
1430
toast.error(t("notifications.cannot_delete_instance"), {
1531
description: error.message

apps/desktop/packages/mainWindow/src/pages/AddonViewPage/index.tsx

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,23 @@ const AddonExplore = () => {
241241
<div class="flex items-center gap-2 p-0 lg:px-2">
242242
<div class="flex gap-2 text-sm">
243243
<Switch>
244-
<Match when={!isFetching() && project.data?.authors && project.data.authors.length > 0}>
244+
<Match
245+
when={
246+
!isFetching() &&
247+
project.data?.authors &&
248+
project.data.authors.length > 0
249+
}
250+
>
245251
<AuthorAvatars
246-
authors={project.data!.authors.map((author): Author => ({
247-
name: author.name,
248-
avatarUrl: author.avatarUrl,
249-
id: author.name, // Use name as ID since FEUnifiedAuthor doesn't have separate ID
250-
platform: project.data!.platform,
251-
url: null // FEUnifiedAuthor doesn't include profile URLs
252-
}))}
252+
authors={project.data!.authors.map(
253+
(author): Author => ({
254+
name: author.name,
255+
avatarUrl: author.avatarUrl,
256+
id: author.name, // Use name as ID since FEUnifiedAuthor doesn't have separate ID
257+
platform: project.data!.platform,
258+
url: null // FEUnifiedAuthor doesn't include profile URLs
259+
})
260+
)}
253261
maxDisplay={4}
254262
size="md"
255263
/>

apps/desktop/packages/mainWindow/src/pages/Library/Instance/Info/Authors.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ const Authors = (props: Props) => {
5555
if (!rawAuthors) return []
5656

5757
if (props.isCurseforge) {
58-
return (rawAuthors as CFFEModAuthor[]).map(author => ({
58+
return (rawAuthors as CFFEModAuthor[]).map((author) => ({
5959
name: author.name,
6060
avatarUrl: author.avatarUrl,
6161
url: author.url,
6262
id: author.id,
6363
platform: "curseforge" as const
6464
}))
6565
} else if (props.isModrinth) {
66-
return (rawAuthors as MRFETeamMember[]).map(member => ({
66+
return (rawAuthors as MRFETeamMember[]).map((member) => ({
6767
name: member.user.name || member.user.username,
6868
avatarUrl: member.user.avatar_url,
6969
role: member.role,

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

Lines changed: 54 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
import { Badge, Button, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Tooltip, TooltipContent, TooltipTrigger } from "@gd/ui"
1+
import {
2+
Badge,
3+
Button,
4+
Select,
5+
SelectContent,
6+
SelectItem,
7+
SelectTrigger,
8+
SelectValue,
9+
Tooltip,
10+
TooltipContent,
11+
TooltipTrigger
12+
} from "@gd/ui"
213
import { For, Show } from "solid-js"
314
import { Trans, useTransContext } from "@gd/i18n"
415
import { AddonType } from "@gd/core_module/bindings"
@@ -64,7 +75,7 @@ export const AddonFilters = (props: AddonFiltersProps) => {
6475
</span>
6576
<Select
6677
value={props.platformFilter()}
67-
onChange={props.setPlatformFilter}
78+
onChange={(value) => value && props.setPlatformFilter(value)}
6879
options={["all", "curseforge", "modrinth", "local"]}
6980
placeholder=""
7081
disallowEmptySelection={true}
@@ -109,43 +120,49 @@ export const AddonFilters = (props: AddonFiltersProps) => {
109120
}}
110121
>
111122
<SelectTrigger class="w-40">
112-
<SelectValue<string>>{(state) => {
113-
const getLabel = (value: string) => {
114-
switch (value) {
115-
case "all":
116-
return t("instance.filter.all")
117-
case "curseforge":
118-
return t("platforms.curseforge")
119-
case "modrinth":
120-
return t("platforms.modrinth")
121-
case "local":
122-
return t("instance.filter.local")
123-
default:
124-
return value
123+
<SelectValue<string>>
124+
{(state) => {
125+
const getLabel = (value: string) => {
126+
switch (value) {
127+
case "all":
128+
return t("instance.filter.all")
129+
case "curseforge":
130+
return t("platforms.curseforge")
131+
case "modrinth":
132+
return t("platforms.modrinth")
133+
case "local":
134+
return t("instance.filter.local")
135+
default:
136+
return value
137+
}
125138
}
126-
}
127-
const getIcon = (value: string) => {
128-
switch (value) {
129-
case "all":
130-
return <div class="i-ri:global-line w-4 h-4" />
131-
case "curseforge":
132-
return <div class="i-simple-icons:curseforge w-4 h-4" />
133-
case "modrinth":
134-
return <div class="i-simple-icons:modrinth w-4 h-4" />
135-
case "local":
136-
return <div class="i-ri:folder-line w-4 h-4" />
137-
default:
138-
return null
139+
const getIcon = (value: string) => {
140+
switch (value) {
141+
case "all":
142+
return <div class="i-ri:global-line w-4 h-4" />
143+
case "curseforge":
144+
return (
145+
<div class="i-simple-icons:curseforge w-4 h-4" />
146+
)
147+
case "modrinth":
148+
return (
149+
<div class="i-simple-icons:modrinth w-4 h-4" />
150+
)
151+
case "local":
152+
return <div class="i-ri:folder-line w-4 h-4" />
153+
default:
154+
return null
155+
}
139156
}
140-
}
141-
const selectedValue = state.selectedOption()
142-
return (
143-
<div class="flex items-center gap-2">
144-
{getIcon(selectedValue)}
145-
{getLabel(selectedValue)}
146-
</div>
147-
)
148-
}}</SelectValue>
157+
const selectedValue = state.selectedOption()
158+
return (
159+
<div class="flex items-center gap-2">
160+
{getIcon(selectedValue)}
161+
{getLabel(selectedValue)}
162+
</div>
163+
)
164+
}}
165+
</SelectValue>
149166
</SelectTrigger>
150167
<SelectContent />
151168
</Select>

apps/desktop/packages/mainWindow/src/pages/Modpacks/useModsQuery.tsx

Lines changed: 0 additions & 42 deletions
This file was deleted.

apps/desktop/packages/mainWindow/src/pages/Mods/useModsQuery.tsx

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)