Skip to content

Commit f01c268

Browse files
committed
add visual feedback for profile switching
1 parent 396ee8c commit f01c268

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/modules/settings/profile/components/ProfileInstalledEntry.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { useCSSLoaderActions, useCSSLoaderValues } from "@/backend";
2-
import { ProfileDetailsModal, useThemeInstallState } from "@/lib";
2+
import { cn, ProfileDetailsModal, useThemeInstallState } from "@/lib";
33
import { Theme } from "@/types";
44
import { DialogButton, Focusable, showModal } from "@decky/ui";
5+
import { useState } from "react";
56
import { FaListUl } from "react-icons/fa6";
67

78
export function ProfileInstalledEntry({
@@ -19,6 +20,8 @@ export function ProfileInstalledEntry({
1920

2021
const isSelected = selectedPreset?.id === data.id;
2122

23+
const [isChanging, setIsChanging] = useState(false);
24+
2225
return (
2326
<Focusable className="relative flex flex-row gap-1">
2427
{updateStatus === "outdated" && (
@@ -38,9 +41,11 @@ export function ProfileInstalledEntry({
3841
<Focusable
3942
ref={passthroughRef}
4043
focusWithinClassName="gpfocuswithin"
41-
onActivate={() => {
42-
if (isSelected) return;
43-
changePreset(data.name);
44+
onActivate={async () => {
45+
if (isSelected || isChanging) return;
46+
setIsChanging(true);
47+
await changePreset(data.name);
48+
setIsChanging(false);
4449
}}
4550
onOKActionDescription="Select Profile"
4651
onOptionsActionDescription="View Details"
@@ -49,7 +54,7 @@ export function ProfileInstalledEntry({
4954
}}
5055
onSecondaryActionDescription={isOutdated ? "Update Profile" : undefined}
5156
onSecondaryButton={isOutdated ? () => installTheme(data.id) : undefined}
52-
className="cl_profilesettings_radiocontainer"
57+
className={cn("cl_profilesettings_radiocontainer", isChanging && "opacity-50")}
5358
>
5459
<span>{data.display_name}</span>
5560
<div className="border-2 border-white rounded-full flex items-center justify-center w-4 h-4 p-1">

0 commit comments

Comments
 (0)