style: auto-fix lint and format

This commit is contained in:
ajnart authored and github-actions[bot] committed 2026-05-29 17:52:12 +00:00
1 parent 5501ee6a7d
commit a2c4b29bfd
4 files changed
+102 -32

No files matched your search

@@ -1,14 +1,68 @@
export const userPreferenceDefinitions = [ export const userPreferenceDefinitions = [
{ key: "colorScheme", kind: "select", guest: true, mutationGroup: "colorScheme", aliases: ["theme", "dark", "light", "auto"] }, {
key: "colorScheme",
kind: "select",
guest: true,
mutationGroup: "colorScheme",
aliases: ["theme", "dark", "light", "auto"],
},
{ key: "locale", kind: "select", guest: true, mutationGroup: "locale", aliases: ["language", "translation"] }, { key: "locale", kind: "select", guest: true, mutationGroup: "locale", aliases: ["language", "translation"] },
{ key: "defaultSearchEngineId", kind: "searchEngine", guest: false, mutationGroup: "searchPreferences", aliases: ["search", "search engine"] }, {
{ key: "openSearchInNewTab", kind: "boolean", guest: false, mutationGroup: "searchPreferences", aliases: ["search", "new tab", "external"] }, key: "defaultSearchEngineId",
{ key: "ddgBangs", kind: "boolean", guest: false, mutationGroup: "searchPreferences", aliases: ["duckduckgo", "bangs", "search"] }, kind: "searchEngine",
{ key: "firstDayOfWeek", kind: "select", guest: false, mutationGroup: "firstDayOfWeek", aliases: ["calendar", "week", "weekday"] }, guest: false,
{ key: "homeBoardId", kind: "board", guest: false, mutationGroup: "homeBoards", aliases: ["home", "board", "dashboard"] }, mutationGroup: "searchPreferences",
{ key: "mobileHomeBoardId", kind: "board", guest: false, mutationGroup: "homeBoards", aliases: ["mobile", "home", "board", "dashboard"] }, aliases: ["search", "search engine"],
{ key: "pingIconsEnabled", kind: "boolean", guest: false, mutationGroup: "pingIconsEnabled", aliases: ["ping", "icon", "status"] }, },
{ key: "fullPreferencesPage", kind: "link", guest: false, mutationGroup: null, aliases: ["settings", "manage", "profile"] }, {
key: "openSearchInNewTab",
kind: "boolean",
guest: false,
mutationGroup: "searchPreferences",
aliases: ["search", "new tab", "external"],
},
{
key: "ddgBangs",
kind: "boolean",
guest: false,
mutationGroup: "searchPreferences",
aliases: ["duckduckgo", "bangs", "search"],
},
{
key: "firstDayOfWeek",
kind: "select",
guest: false,
mutationGroup: "firstDayOfWeek",
aliases: ["calendar", "week", "weekday"],
},
{
key: "homeBoardId",
kind: "board",
guest: false,
mutationGroup: "homeBoards",
aliases: ["home", "board", "dashboard"],
},
{
key: "mobileHomeBoardId",
kind: "board",
guest: false,
mutationGroup: "homeBoards",
aliases: ["mobile", "home", "board", "dashboard"],
},
{
key: "pingIconsEnabled",
kind: "boolean",
guest: false,
mutationGroup: "pingIconsEnabled",
aliases: ["ping", "icon", "status"],
},
{
key: "fullPreferencesPage",
kind: "link",
guest: false,
mutationGroup: null,
aliases: ["settings", "manage", "profile"],
},
] as const; ] as const;
export type UserPreferenceDefinition = (typeof userPreferenceDefinitions)[number]; export type UserPreferenceDefinition = (typeof userPreferenceDefinitions)[number];
@@ -26,7 +26,17 @@ type SettingsAction = ChildrenAction<Record<string, unknown>>;
const weekDays = dayjs.weekdays(false); const weekDays = dayjs.weekdays(false);
const BooleanRow = ({ label, Icon, checked, isPending }: { label: string; Icon: TablerIcon; checked: boolean; isPending: boolean }) => ( const BooleanRow = ({
label,
Icon,
checked,
isPending,
}: {
label: string;
Icon: TablerIcon;
checked: boolean;
isPending: boolean;
}) => (
<Group mx="md" my="sm" wrap="nowrap" justify="space-between" w="100%"> <Group mx="md" my="sm" wrap="nowrap" justify="space-between" w="100%">
<Group wrap="nowrap" gap="sm"> <Group wrap="nowrap" gap="sm">
<Icon stroke={1.5} size={20} /> <Icon stroke={1.5} size={20} />
@@ -42,7 +52,9 @@ const SelectRow = ({ label, Icon, valueLabel }: { label: string; Icon: TablerIco
<Icon stroke={1.5} size={20} /> <Icon stroke={1.5} size={20} />
<Text>{label}</Text> <Text>{label}</Text>
</Group> </Group>
<Text size="sm" c="dimmed">{valueLabel}</Text> <Text size="sm" c="dimmed">
{valueLabel}
</Text>
</Group> </Group>
); );
@@ -73,12 +85,15 @@ const useSettingsActions = (_: Record<string, unknown>, query: string): Settings
return localeConfigurations[val as keyof typeof localeConfigurations]?.name ?? String(val); return localeConfigurations[val as keyof typeof localeConfigurations]?.name ?? String(val);
}, },
defaultSearchEngineId: () => defaultSearchEngineId: () =>
searchEnginesQuery.data?.find((e) => e.value === preferences.getPreference("defaultSearchEngineId").value)?.label ?? t("searchEngine.none" as never), searchEnginesQuery.data?.find((e) => e.value === preferences.getPreference("defaultSearchEngineId").value)
?.label ?? t("searchEngine.none" as never),
firstDayOfWeek: () => weekDays[preferences.getPreference("firstDayOfWeek").value as DayOfWeek] ?? "", firstDayOfWeek: () => weekDays[preferences.getPreference("firstDayOfWeek").value as DayOfWeek] ?? "",
homeBoardId: () => homeBoardId: () =>
boardsQuery.data?.find((b) => b.id === preferences.getPreference("homeBoardId").value)?.name ?? t("board.none" as never), boardsQuery.data?.find((b) => b.id === preferences.getPreference("homeBoardId").value)?.name ??
t("board.none" as never),
mobileHomeBoardId: () => mobileHomeBoardId: () =>
boardsQuery.data?.find((b) => b.id === preferences.getPreference("mobileHomeBoardId").value)?.name ?? t("board.none" as never), boardsQuery.data?.find((b) => b.id === preferences.getPreference("mobileHomeBoardId").value)?.name ??
t("board.none" as never),
}; };
return visiblePreferenceDefinitions(isAuthenticated) return visiblePreferenceDefinitions(isAuthenticated)
@@ -93,7 +108,9 @@ const useSettingsActions = (_: Record<string, unknown>, query: string): Settings
const pref = preferences.getPreference(definition.key); const pref = preferences.getPreference(definition.key);
return { return {
key: definition.key, key: definition.key,
Component: () => <BooleanRow label={label} Icon={Icon} checked={pref.value as boolean} isPending={pref.isPending} />, Component: () => (
<BooleanRow label={label} Icon={Icon} checked={pref.value as boolean} isPending={pref.isPending} />
),
useInteraction: interaction.javaScript(() => ({ useInteraction: interaction.javaScript(() => ({
onSelect: pref.isPending ? () => undefined : () => pref.setValue(!(pref.value as boolean) as never), onSelect: pref.isPending ? () => undefined : () => pref.setValue(!(pref.value as boolean) as never),
closeSpotlightOnTrigger: false, closeSpotlightOnTrigger: false,
@@ -114,7 +131,9 @@ const useSettingsActions = (_: Record<string, unknown>, query: string): Settings
if (!children) return null; if (!children) return null;
return { return {
key: definition.key, key: definition.key,
Component: () => <SelectRow label={label} Icon={Icon} valueLabel={valueLabelResolvers[definition.key]?.() ?? ""} />, Component: () => (
<SelectRow label={label} Icon={Icon} valueLabel={valueLabelResolvers[definition.key]?.() ?? ""} />
),
useInteraction: interaction.children(children), useInteraction: interaction.children(children),
}; };
} }
@@ -131,7 +150,9 @@ export const settingsChildrenOptions = createChildrenOptions<Record<string, unkn
return ( return (
<Stack mx="md" my="sm" gap="xs"> <Stack mx="md" my="sm" gap="xs">
<Text>{t("title")}</Text> <Text>{t("title")}</Text>
<Text size="xs" c="dimmed">{t("children.detail.backHint")}</Text> <Text size="xs" c="dimmed">
{t("children.detail.backHint")}
</Text>
</Stack> </Stack>
); );
}, },
@@ -10,9 +10,7 @@ import { createGroup } from "../../lib/group";
import { preferenceChildrenOptionsByKey, preferenceIcons } from "../../preferences/preference-registry"; import { preferenceChildrenOptionsByKey, preferenceIcons } from "../../preferences/preference-registry";
import { settingsChildrenOptions } from "../command/children/preferences/settings-children"; import { settingsChildrenOptions } from "../command/children/preferences/settings-children";
type PreferencesGroupOption = type PreferencesGroupOption = { key: "settings"; preferenceKey: null } | { key: string; preferenceKey: string };
| { key: "settings"; preferenceKey: null }
| { key: string; preferenceKey: string };
const settingsOption: PreferencesGroupOption = { key: "settings", preferenceKey: null }; const settingsOption: PreferencesGroupOption = { key: "settings", preferenceKey: null };
@@ -10,10 +10,7 @@ import { useSession } from "@homarr/auth/client";
import type { ColorScheme } from "@homarr/definitions"; import type { ColorScheme } from "@homarr/definitions";
import { showErrorNotification } from "@homarr/notifications"; import { showErrorNotification } from "@homarr/notifications";
import type { SettingsContextProps } from "@homarr/settings/creator"; import type { SettingsContextProps } from "@homarr/settings/creator";
import { import { userPreferenceDefinitions, userPreferenceDefinitionByKey } from "@homarr/settings";
userPreferenceDefinitions,
userPreferenceDefinitionByKey,
} from "@homarr/settings";
import type { UserPreferenceKey } from "@homarr/settings"; import type { UserPreferenceKey } from "@homarr/settings";
import { useSettings } from "@homarr/settings"; import { useSettings } from "@homarr/settings";
import { useChangeLocale, useCurrentLocale, useI18n } from "@homarr/translation/client"; import { useChangeLocale, useCurrentLocale, useI18n } from "@homarr/translation/client";
@@ -77,7 +74,11 @@ export const useUserPreferences = () => {
const userId = session?.user.id; const userId = session?.user.id;
const pendingRef = useRef<Record<string, boolean>>({}); const pendingRef = useRef<Record<string, boolean>>({});
useSyncExternalStore(subscribeOptimistic, () => optimisticVersion, () => optimisticVersion); useSyncExternalStore(
subscribeOptimistic,
() => optimisticVersion,
() => optimisticVersion,
);
const refresh = () => router.refresh(); const refresh = () => router.refresh();
@@ -87,9 +88,7 @@ export const useUserPreferences = () => {
const pingMutation = clientApi.user.changePingIconsEnabled.useMutation({ onSuccess: refresh }); const pingMutation = clientApi.user.changePingIconsEnabled.useMutation({ onSuccess: refresh });
const getEffective = (key: UserPreferenceKey): unknown => const getEffective = (key: UserPreferenceKey): unknown =>
key in optimisticRef.current key in optimisticRef.current ? optimisticRef.current[key] : settingsRef.current[key as keyof SettingsContextProps];
? optimisticRef.current[key]
: settingsRef.current[key as keyof SettingsContextProps];
const pick = (field: UserPreferenceKey, changedKey: UserPreferenceKey, value: unknown) => const pick = (field: UserPreferenceKey, changedKey: UserPreferenceKey, value: unknown) =>
field === changedKey ? value : getEffective(field); field === changedKey ? value : getEffective(field);
@@ -108,10 +107,8 @@ export const useUserPreferences = () => {
homeBoardId: pick("homeBoardId", key, value) as string | null, homeBoardId: pick("homeBoardId", key, value) as string | null,
mobileHomeBoardId: pick("mobileHomeBoardId", key, value) as string | null, mobileHomeBoardId: pick("mobileHomeBoardId", key, value) as string | null,
}), }),
firstDayOfWeek: (_key, value) => firstDayOfWeek: (_key, value) => firstDayMutation.mutateAsync({ id: userId!, firstDayOfWeek: value as DayOfWeek }),
firstDayMutation.mutateAsync({ id: userId!, firstDayOfWeek: value as DayOfWeek }), pingIconsEnabled: (_key, value) => pingMutation.mutateAsync({ id: userId!, pingIconsEnabled: value as boolean }),
pingIconsEnabled: (_key, value) =>
pingMutation.mutateAsync({ id: userId!, pingIconsEnabled: value as boolean }),
}; };
const groupPending: Record<string, boolean> = { const groupPending: Record<string, boolean> = {