Refactor settings management and add mutation error handling
All checks were successful
Deploy to production / build (push) Successful in 18s
All checks were successful
Deploy to production / build (push) Successful in 18s
This commit is contained in:
60
src/App.tsx
60
src/App.tsx
@@ -37,17 +37,11 @@ function App() {
|
|||||||
const { data: themePlaylists, isFetched: isThemePlaylistsFetched } = useQueryAPI({
|
const { data: themePlaylists, isFetched: isThemePlaylistsFetched } = useQueryAPI({
|
||||||
endpoint: 'api/themePlaylists',
|
endpoint: 'api/themePlaylists',
|
||||||
});
|
});
|
||||||
const { data: personalData, isFetched: isPersonalDataFetched } = useQueryAPI({
|
const { data: personalData } = useQueryAPI({
|
||||||
endpoint: 'api/personalData',
|
endpoint: 'api/personalData',
|
||||||
});
|
});
|
||||||
const {
|
const { settings, updateSetting, theme, setTheme, handleThemeChange } =
|
||||||
theme,
|
useCommonHooks();
|
||||||
setTheme,
|
|
||||||
themeName,
|
|
||||||
setThemeName,
|
|
||||||
handleThemeChange,
|
|
||||||
currentThemePlaylist,
|
|
||||||
} = useCommonHooks();
|
|
||||||
const [loaded, setLoaded] = useState<boolean>(false);
|
const [loaded, setLoaded] = useState<boolean>(false);
|
||||||
const overrides = createTheme({
|
const overrides = createTheme({
|
||||||
primaryColor: 'primary',
|
primaryColor: 'primary',
|
||||||
@@ -68,22 +62,23 @@ function App() {
|
|||||||
'shift + t',
|
'shift + t',
|
||||||
() => {
|
() => {
|
||||||
const themeList = JSON.parse(
|
const themeList = JSON.parse(
|
||||||
themePlaylists?.find((t: ThemePlaylist) => t?.name === currentThemePlaylist)
|
themePlaylists?.find(
|
||||||
?.themeList ?? '[]',
|
(t: ThemePlaylist) => t?.name === settings.currentThemePlaylist,
|
||||||
|
)?.themeList ?? '[]',
|
||||||
);
|
);
|
||||||
if (themeList.length > 0 && currentThemePlaylist !== 'Time of Day') {
|
if (themeList.length > 0 && settings.currentThemePlaylist !== 'Time of Day') {
|
||||||
const filteredThemes = allThemes.filter((t: Theme) => themeList.includes(t.id));
|
const filteredThemes = allThemes.filter((t: Theme) => themeList.includes(t.id));
|
||||||
handleThemeChange(filteredThemes, false);
|
handleThemeChange(filteredThemes, false);
|
||||||
} else if (currentThemePlaylist === 'All') {
|
} else if (settings.currentThemePlaylist === 'All') {
|
||||||
handleThemeChange(allThemes, true);
|
handleThemeChange(allThemes, true);
|
||||||
} else if (currentThemePlaylist === 'Backgrounds') {
|
} else if (settings.currentThemePlaylist === 'Backgrounds') {
|
||||||
handleThemeChange(
|
handleThemeChange(
|
||||||
allThemes.filter(
|
allThemes.filter(
|
||||||
(a: any) => !a.backgroundImage.toLowerCase().includes('none'),
|
(a: any) => !a.backgroundImage.toLowerCase().includes('none'),
|
||||||
),
|
),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
} else if (currentThemePlaylist === 'No Backgrounds') {
|
} else if (settings.currentThemePlaylist === 'No Backgrounds') {
|
||||||
handleThemeChange(
|
handleThemeChange(
|
||||||
allThemes.filter((a: any) =>
|
allThemes.filter((a: any) =>
|
||||||
a.backgroundImage.toLowerCase().includes('none'),
|
a.backgroundImage.toLowerCase().includes('none'),
|
||||||
@@ -119,22 +114,26 @@ function App() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (
|
||||||
allThemes &&
|
allThemes &&
|
||||||
themeName &&
|
settings.theme &&
|
||||||
personalData &&
|
personalData &&
|
||||||
Object.keys(personalData).length > 0 &&
|
Object.keys(personalData).length > 0 &&
|
||||||
isThemePlaylistsFetched
|
isThemePlaylistsFetched
|
||||||
) {
|
) {
|
||||||
if (currentThemePlaylist === 'All') {
|
Object.keys(personalData[0]).forEach((key: any) => {
|
||||||
if (themeName === 'random') {
|
updateSetting(key, personalData[0][key]);
|
||||||
|
});
|
||||||
|
if (settings.currentThemePlaylist === 'All') {
|
||||||
|
if (settings.theme === 'random') {
|
||||||
handleThemeChange(allThemes, false);
|
handleThemeChange(allThemes, false);
|
||||||
} else {
|
} else {
|
||||||
const temp = allThemes.find((t: Theme) => t.name === themeName);
|
const temp = allThemes.find((t: Theme) => t.name === settings.theme);
|
||||||
setTheme(temp);
|
setTheme(temp);
|
||||||
}
|
}
|
||||||
} else if (currentThemePlaylist === 'Time of Day') {
|
} else if (settings.currentThemePlaylist === 'Time of Day') {
|
||||||
const themeList = JSON.parse(
|
const themeList = JSON.parse(
|
||||||
themePlaylists?.find((t: ThemePlaylist) => t.name === currentThemePlaylist)
|
themePlaylists?.find(
|
||||||
.themeList,
|
(t: ThemePlaylist) => t.name === settings.currentThemePlaylist,
|
||||||
|
).themeList,
|
||||||
);
|
);
|
||||||
setTheme(
|
setTheme(
|
||||||
allThemes.find(
|
allThemes.find(
|
||||||
@@ -142,34 +141,35 @@ function App() {
|
|||||||
t.id === Number(themeList[Math.floor(new Date().getHours() / 6)]),
|
t.id === Number(themeList[Math.floor(new Date().getHours() / 6)]),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else if (currentThemePlaylist === 'Backgrounds') {
|
} else if (settings.currentThemePlaylist === 'Backgrounds') {
|
||||||
handleThemeChange(
|
handleThemeChange(
|
||||||
allThemes.filter((a: any) => !a.backgroundImage.toLowerCase().includes('none')),
|
allThemes.filter((a: any) => !a.backgroundImage.toLowerCase().includes('none')),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
} else if (currentThemePlaylist === 'No Backgrounds') {
|
} else if (settings.currentThemePlaylist === 'No Backgrounds') {
|
||||||
handleThemeChange(
|
handleThemeChange(
|
||||||
allThemes.filter((a: any) => a.backgroundImage.toLowerCase().includes('none')),
|
allThemes.filter((a: any) => a.backgroundImage.toLowerCase().includes('none')),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const themeList = JSON.parse(
|
const themeList = JSON.parse(
|
||||||
themePlaylists?.find((t: ThemePlaylist) => t.name === currentThemePlaylist)
|
themePlaylists?.find(
|
||||||
.themeList,
|
(t: ThemePlaylist) => t.name === settings.currentThemePlaylist,
|
||||||
|
).themeList,
|
||||||
);
|
);
|
||||||
const filteredThemes = allThemes.filter((t: Theme) => themeList.includes(t.id));
|
const filteredThemes = allThemes.filter((t: Theme) => themeList.includes(t.id));
|
||||||
setThemeName('random');
|
updateSetting('theme', 'random');
|
||||||
handleThemeChange(filteredThemes, false);
|
handleThemeChange(filteredThemes, false);
|
||||||
}
|
}
|
||||||
setLoaded(true);
|
setLoaded(true);
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
isAllThemesFetched,
|
isAllThemesFetched,
|
||||||
themeName,
|
settings.theme,
|
||||||
allThemes,
|
allThemes,
|
||||||
currentThemePlaylist,
|
settings.currentThemePlaylist,
|
||||||
isThemePlaylistsFetched,
|
isThemePlaylistsFetched,
|
||||||
isPersonalDataFetched,
|
personalData,
|
||||||
]);
|
]);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export function WeatherModal({
|
|||||||
handleResetSearch: () => void;
|
handleResetSearch: () => void;
|
||||||
closeWeatherModal: () => void;
|
closeWeatherModal: () => void;
|
||||||
}) {
|
}) {
|
||||||
const { isMobile, currentUser } = useCommonHooks();
|
const { isMobile, settings } = useCommonHooks();
|
||||||
const [selectedDay, setSelectedDay] = useState<any>(undefined);
|
const [selectedDay, setSelectedDay] = useState<any>(undefined);
|
||||||
const [selectedHourly, setSelectedHourly] = useState<any>(undefined);
|
const [selectedHourly, setSelectedHourly] = useState<any>(undefined);
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ export function WeatherModal({
|
|||||||
Weather Forecast for{' '}
|
Weather Forecast for{' '}
|
||||||
</Text>
|
</Text>
|
||||||
<Text fz={'1.125rem'} fw={600}>
|
<Text fz={'1.125rem'} fw={600}>
|
||||||
{currentUser.physicalAddress}
|
{settings.physicalAddress}
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
</Modal.Title>
|
</Modal.Title>
|
||||||
|
|||||||
@@ -306,23 +306,53 @@ export function useMutationAPI() {
|
|||||||
body: object | undefined | null;
|
body: object | undefined | null;
|
||||||
}) => callEndpoint(method, endpoint, body),
|
}) => callEndpoint(method, endpoint, body),
|
||||||
onSuccess: (_, { endpoint }) => {
|
onSuccess: (_, { endpoint }) => {
|
||||||
queryClient.refetchQueries({
|
queryClient
|
||||||
|
.refetchQueries({
|
||||||
queryKey: ['GET', endpoint],
|
queryKey: ['GET', endpoint],
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
endpoint === 'api/bookmarkOrder' &&
|
endpoint === 'api/bookmarkOrder' &&
|
||||||
queryClient.refetchQueries({ queryKey: ['GET', 'api/bookmarks'] });
|
queryClient
|
||||||
|
.refetchQueries({ queryKey: ['GET', 'api/bookmarks'] })
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
endpoint === 'api/bookmarkCategoryOrder' &&
|
endpoint === 'api/bookmarkCategoryOrder' &&
|
||||||
queryClient.refetchQueries({ queryKey: ['GET', 'api/bookmarkCategories'] });
|
queryClient
|
||||||
|
.refetchQueries({ queryKey: ['GET', 'api/bookmarkCategories'] })
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
endpoint === 'api/applicationOrder' &&
|
endpoint === 'api/applicationOrder' &&
|
||||||
queryClient.refetchQueries({ queryKey: ['GET', 'api/applications'] });
|
queryClient
|
||||||
|
.refetchQueries({ queryKey: ['GET', 'api/applications'] })
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
endpoint === 'api/applications' &&
|
endpoint === 'api/applications' &&
|
||||||
queryClient.refetchQueries({ queryKey: ['GET', 'api/enabledApplications'] });
|
queryClient
|
||||||
|
.refetchQueries({ queryKey: ['GET', 'api/enabledApplications'] })
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
endpoint === 'api/bookmarks' &&
|
endpoint === 'api/bookmarks' &&
|
||||||
queryClient.refetchQueries({ queryKey: ['GET', 'api/themes'] });
|
queryClient.refetchQueries({ queryKey: ['GET', 'api/themes'] }).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
endpoint === 'api/providers' &&
|
endpoint === 'api/providers' &&
|
||||||
queryClient.refetchQueries({ queryKey: ['GET', 'api/providers/default'] });
|
queryClient
|
||||||
|
.refetchQueries({ queryKey: ['GET', 'api/providers/default'] })
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
endpoint === 'api/personalData' &&
|
endpoint === 'api/personalData' &&
|
||||||
queryClient.refetchQueries({ queryKey: ['GET', 'api/personalData'] });
|
queryClient
|
||||||
|
.refetchQueries({ queryKey: ['GET', 'api/personalData'] })
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -426,9 +456,21 @@ export function useFileUploadAPI() {
|
|||||||
}) => callEndpoint(method, endpoint, body),
|
}) => callEndpoint(method, endpoint, body),
|
||||||
onMutate: () => {},
|
onMutate: () => {},
|
||||||
onSuccess: (_variables) => {
|
onSuccess: (_variables) => {
|
||||||
queryClient.invalidateQueries({ queryKey: ['GET', 'api/backgrounds'] });
|
queryClient
|
||||||
queryClient.invalidateQueries({ queryKey: ['GET', 'api/themes'] });
|
.invalidateQueries({ queryKey: ['GET', 'api/backgrounds'] })
|
||||||
queryClient.invalidateQueries({ queryKey: ['GET', 'api/themePlaylists'] });
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
|
queryClient
|
||||||
|
.invalidateQueries({ queryKey: ['GET', 'api/themes'] })
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
|
queryClient
|
||||||
|
.invalidateQueries({ queryKey: ['GET', 'api/themePlaylists'] })
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,98 +2,25 @@ import { useLocalStorage } from '@mantine/hooks';
|
|||||||
import { appTheme } from 'contexts';
|
import { appTheme } from 'contexts';
|
||||||
import { useAtom } from 'jotai';
|
import { useAtom } from 'jotai';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import type { Location, Theme, User } from 'types';
|
import type { Settings, Theme } from 'types';
|
||||||
import { useMutationAPI } from './useAPI';
|
import { useMutationAPI } from './useAPI';
|
||||||
|
|
||||||
export function useCommonHooks() {
|
const initialSettings: Settings = {
|
||||||
const { mutateAsync } = useMutationAPI();
|
theme: 'random',
|
||||||
const isMobile = globalThis.matchMedia('(max-width: 600px)').matches;
|
appFilter: ['All'],
|
||||||
const [theme, setTheme] = useAtom<Theme>(appTheme);
|
appSort: 'A>Z',
|
||||||
const [themeName, setThemeName] = useLocalStorage<string>({
|
appDensity: 6,
|
||||||
key: 'theme',
|
appScale: 1,
|
||||||
defaultValue: 'random',
|
bookmarkSort: 'A>Z',
|
||||||
});
|
bookmarkFilter: ['All'],
|
||||||
const [appFilter, setAppFilter] = useLocalStorage<string[]>({
|
bookmarkDensity: 6,
|
||||||
key: 'appFilter',
|
bookmarkScale: 1,
|
||||||
defaultValue: ['All'],
|
currentThemePlaylist: 'All',
|
||||||
});
|
defaultProviderLabel: 'Google Search',
|
||||||
const [appSort, setAppSort] = useLocalStorage<string>({
|
defaultProviderURL: 'https://www.google.com/search?q=',
|
||||||
key: 'appSort',
|
defaultProviderPrefix: '/g',
|
||||||
defaultValue: 'A>Z',
|
defaultProviderIcon: 'FaGoogle',
|
||||||
});
|
timeFormat: '12h',
|
||||||
const [appDensity, setAppDensity] = useLocalStorage<number>({
|
|
||||||
key: 'appDensity',
|
|
||||||
defaultValue: 6,
|
|
||||||
});
|
|
||||||
const [appScale, setAppScale] = useLocalStorage<number>({
|
|
||||||
key: 'appScale',
|
|
||||||
defaultValue: 1,
|
|
||||||
});
|
|
||||||
const [bookmarkSort, setBookmarkSort] = useLocalStorage<string>({
|
|
||||||
key: 'bookmarkSort',
|
|
||||||
defaultValue: 'A>Z',
|
|
||||||
});
|
|
||||||
const [bookmarkFilter, setBookmarkFilter] = useLocalStorage<string[]>({
|
|
||||||
key: 'bookmarkFilter',
|
|
||||||
defaultValue: ['All'],
|
|
||||||
});
|
|
||||||
const [bookmarkDensity, setBookmarkDensity] = useLocalStorage<number>({
|
|
||||||
key: 'bookmarkDensity',
|
|
||||||
defaultValue: 6,
|
|
||||||
});
|
|
||||||
const [bookmarkScale, setBookmarkScale] = useLocalStorage<number>({
|
|
||||||
key: 'bookmarkScale',
|
|
||||||
defaultValue: 1,
|
|
||||||
});
|
|
||||||
const [currentTheme, setCurrentTheme] = useLocalStorage<string>({
|
|
||||||
key: 'theme',
|
|
||||||
defaultValue: 'random',
|
|
||||||
});
|
|
||||||
const [currentThemePlaylist, setCurrentThemePlaylist] = useLocalStorage<string>({
|
|
||||||
key: 'themePlaylist',
|
|
||||||
defaultValue: 'All',
|
|
||||||
});
|
|
||||||
const [defaultProviderLabel, setDefaultProviderLabel] = useLocalStorage<string>({
|
|
||||||
key: 'providerLabel',
|
|
||||||
defaultValue: 'Google Search',
|
|
||||||
});
|
|
||||||
const [defaultProviderURL, setDefaultProviderURL] = useLocalStorage<string>({
|
|
||||||
key: 'providerURL',
|
|
||||||
defaultValue: 'https://www.google.com/search?q=',
|
|
||||||
});
|
|
||||||
const [defaultProviderPrefix, setDefaultProviderPrefix] = useLocalStorage<string>({
|
|
||||||
key: 'providerPrefix',
|
|
||||||
defaultValue: '/g',
|
|
||||||
});
|
|
||||||
const [defaultProviderIcon, setDefaultProviderIcon] = useLocalStorage<string>({
|
|
||||||
key: 'providerIcon',
|
|
||||||
defaultValue: 'FaGoogle',
|
|
||||||
});
|
|
||||||
const [timeFormat, setTimeFormat] = useLocalStorage<string>({
|
|
||||||
key: 'timeFormat',
|
|
||||||
defaultValue: '12h',
|
|
||||||
});
|
|
||||||
const [searchValue, setSearchValue] = useState<string>('');
|
|
||||||
const [providerLabel, setProviderLabel] = useState(defaultProviderLabel);
|
|
||||||
const [providerURL, setProviderURL] = useState(defaultProviderURL);
|
|
||||||
const [providerPrefix, setProviderPrefix] = useState(defaultProviderPrefix);
|
|
||||||
const [providerIcon, setProviderIcon] = useState(defaultProviderIcon);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setProviderLabel(defaultProviderLabel);
|
|
||||||
setProviderURL(defaultProviderURL);
|
|
||||||
setProviderPrefix(defaultProviderPrefix);
|
|
||||||
setProviderIcon(defaultProviderIcon);
|
|
||||||
}, [
|
|
||||||
defaultProviderLabel,
|
|
||||||
defaultProviderURL,
|
|
||||||
defaultProviderPrefix,
|
|
||||||
defaultProviderIcon,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const [currentUser, setCurrentUser] = useLocalStorage<User>({
|
|
||||||
key: 'user',
|
|
||||||
defaultValue: {
|
|
||||||
firstName: 'First',
|
firstName: 'First',
|
||||||
lastName: 'Last',
|
lastName: 'Last',
|
||||||
nickname: 'Boss',
|
nickname: 'Boss',
|
||||||
@@ -103,25 +30,45 @@ export function useCommonHooks() {
|
|||||||
enableWol: 0,
|
enableWol: 0,
|
||||||
enableGuacamole: 0,
|
enableGuacamole: 0,
|
||||||
guacamoleHost: 'https://domain.example.com/guacamole',
|
guacamoleHost: 'https://domain.example.com/guacamole',
|
||||||
},
|
|
||||||
});
|
|
||||||
const [currentLocation, setCurrentLocation] = useLocalStorage<Location>({
|
|
||||||
key: 'location',
|
|
||||||
defaultValue: {
|
|
||||||
lat: 29.750950134386066,
|
lat: 29.750950134386066,
|
||||||
lon: -95.36220654860034,
|
lon: -95.36220654860034,
|
||||||
},
|
};
|
||||||
|
|
||||||
|
export function useCommonHooks() {
|
||||||
|
const { mutateAsync } = useMutationAPI();
|
||||||
|
const isMobile = globalThis.matchMedia('(max-width: 600px)').matches;
|
||||||
|
const [theme, setTheme] = useAtom<Theme>(appTheme);
|
||||||
|
|
||||||
|
const [settings, setSettings] = useLocalStorage<Settings>({
|
||||||
|
key: 'trigger_settings',
|
||||||
|
defaultValue: initialSettings,
|
||||||
});
|
});
|
||||||
|
|
||||||
const urlPattern = new RegExp(
|
// Helper to update specific keys without wiping the rest of the object
|
||||||
String.raw`^(https?:\/\/)?` +
|
const updateSetting = <K extends keyof Settings>(key: K, value: Settings[K]) => {
|
||||||
String.raw`((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|` +
|
setSettings((prev) => ({ ...prev, [key]: value }));
|
||||||
String.raw`((\d{1,3}\.){3}\d{1,3}))` +
|
};
|
||||||
String.raw`(\:\d+)?(\/[-a-z\d%_.~+]*)*` +
|
|
||||||
String.raw`(\?[;&a-z\d%_.~+=-]*)?` +
|
const [searchValue, setSearchValue] = useState<string>('');
|
||||||
String.raw`(\#[-a-z\d_]*)?$`,
|
const [providerLabel, setProviderLabel] = useState(settings.defaultProviderLabel);
|
||||||
'i',
|
const [providerURL, setProviderURL] = useState(settings.defaultProviderURL);
|
||||||
);
|
const [providerPrefix, setProviderPrefix] = useState(settings.defaultProviderPrefix);
|
||||||
|
const [providerIcon, setProviderIcon] = useState(settings.defaultProviderIcon);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setProviderLabel(settings.defaultProviderLabel);
|
||||||
|
setProviderURL(settings.defaultProviderURL);
|
||||||
|
setProviderPrefix(settings.defaultProviderPrefix);
|
||||||
|
setProviderIcon(settings.defaultProviderIcon);
|
||||||
|
}, [
|
||||||
|
settings.defaultProviderLabel,
|
||||||
|
settings.defaultProviderURL,
|
||||||
|
settings.defaultProviderPrefix,
|
||||||
|
settings.defaultProviderIcon,
|
||||||
|
]);
|
||||||
|
|
||||||
|
const urlPattern =
|
||||||
|
/^(https?:\/\/)?([\w.-]+)\.([a-z]{2,})(:\d+)?(\/[-a-z\d%_.~+]*)*(\?[;&a-z\d%_.~+=-]*)?(#[-a-z\d_]*)?$/i;
|
||||||
|
|
||||||
const textShadowStyle =
|
const textShadowStyle =
|
||||||
'1px 1px 1px color-mix(in srgb, var(--mantine-color-accent-0), transparent 50%)';
|
'1px 1px 1px color-mix(in srgb, var(--mantine-color-accent-0), transparent 50%)';
|
||||||
@@ -139,22 +86,24 @@ export function useCommonHooks() {
|
|||||||
const enabled = themes
|
const enabled = themes
|
||||||
.filter((t: Theme) => t.randomEnabled === 1)
|
.filter((t: Theme) => t.randomEnabled === 1)
|
||||||
.filter((t: Theme) => t.name !== theme.name);
|
.filter((t: Theme) => t.name !== theme.name);
|
||||||
if (enabled.length === 0 && currentThemePlaylist === 'All') {
|
if (enabled.length === 0 && settings.currentThemePlaylist === 'All') {
|
||||||
setTheme(themes[0]);
|
setTheme(themes[0]);
|
||||||
save && setThemeName(themes[0].name);
|
if (save) updateSetting('theme', themes[0].name);
|
||||||
} else if (currentThemePlaylist === 'All') {
|
} else if (settings.currentThemePlaylist === 'All') {
|
||||||
const index = Math.floor(Math.random() * enabled.length);
|
const index = Math.floor(Math.random() * enabled.length);
|
||||||
setTheme(enabled[index]);
|
setTheme(enabled[index]);
|
||||||
save && setThemeName(enabled[index].name);
|
if (save) updateSetting('theme', enabled[index].name);
|
||||||
} else {
|
} else {
|
||||||
const index = Math.floor(Math.random() * themes.length);
|
const index = Math.floor(Math.random() * themes.length);
|
||||||
setTheme(themes[index]);
|
setTheme(themes[index]);
|
||||||
save && setThemeName(themes[index].name);
|
if (save) updateSetting('theme', themes[index].name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDelete = (item: any, endpoint: string) => {
|
const handleDelete = (item: any, endpoint: string) => {
|
||||||
mutateAsync({ method: 'DELETE', endpoint: endpoint, body: item });
|
mutateAsync({ method: 'DELETE', endpoint: endpoint, body: item }).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const iconFilter = (selectedTheme?: Theme) => {
|
const iconFilter = (selectedTheme?: Theme) => {
|
||||||
@@ -178,7 +127,6 @@ export function useCommonHooks() {
|
|||||||
const getObjectDiff = (original: any, current: any) => {
|
const getObjectDiff = (original: any, current: any) => {
|
||||||
const changes: any = {};
|
const changes: any = {};
|
||||||
|
|
||||||
// Check current object's properties
|
|
||||||
for (const [key, value] of Object.entries(current)) {
|
for (const [key, value] of Object.entries(current)) {
|
||||||
if (!(key in original)) {
|
if (!(key in original)) {
|
||||||
changes[key] = {
|
changes[key] = {
|
||||||
@@ -191,7 +139,6 @@ export function useCommonHooks() {
|
|||||||
const originalValue = original[key];
|
const originalValue = original[key];
|
||||||
const currentValue = value;
|
const currentValue = value;
|
||||||
|
|
||||||
// Handle different types of comparisons
|
|
||||||
if (
|
if (
|
||||||
originalValue !== currentValue &&
|
originalValue !== currentValue &&
|
||||||
String(originalValue) !== String(currentValue) &&
|
String(originalValue) !== String(currentValue) &&
|
||||||
@@ -204,7 +151,6 @@ export function useCommonHooks() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for removed properties
|
|
||||||
for (const key of Object.keys(original)) {
|
for (const key of Object.keys(original)) {
|
||||||
if (!(key in current)) {
|
if (!(key in current)) {
|
||||||
changes[key] = {
|
changes[key] = {
|
||||||
@@ -218,6 +164,8 @@ export function useCommonHooks() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
settings,
|
||||||
|
updateSetting,
|
||||||
isMobile,
|
isMobile,
|
||||||
theme,
|
theme,
|
||||||
setTheme,
|
setTheme,
|
||||||
@@ -228,28 +176,6 @@ export function useCommonHooks() {
|
|||||||
getObjectDiff,
|
getObjectDiff,
|
||||||
handleThemeChange,
|
handleThemeChange,
|
||||||
handleDelete,
|
handleDelete,
|
||||||
themeName,
|
|
||||||
setThemeName,
|
|
||||||
appFilter,
|
|
||||||
setAppFilter,
|
|
||||||
appSort,
|
|
||||||
setAppSort,
|
|
||||||
appDensity,
|
|
||||||
setAppDensity,
|
|
||||||
appScale,
|
|
||||||
setAppScale,
|
|
||||||
bookmarkSort,
|
|
||||||
setBookmarkSort,
|
|
||||||
bookmarkFilter,
|
|
||||||
setBookmarkFilter,
|
|
||||||
bookmarkDensity,
|
|
||||||
setBookmarkDensity,
|
|
||||||
bookmarkScale,
|
|
||||||
setBookmarkScale,
|
|
||||||
currentTheme,
|
|
||||||
setCurrentTheme,
|
|
||||||
currentThemePlaylist,
|
|
||||||
setCurrentThemePlaylist,
|
|
||||||
searchValue,
|
searchValue,
|
||||||
setSearchValue,
|
setSearchValue,
|
||||||
providerLabel,
|
providerLabel,
|
||||||
@@ -260,20 +186,6 @@ export function useCommonHooks() {
|
|||||||
setProviderPrefix,
|
setProviderPrefix,
|
||||||
providerIcon,
|
providerIcon,
|
||||||
setProviderIcon,
|
setProviderIcon,
|
||||||
defaultProviderLabel,
|
|
||||||
setDefaultProviderLabel,
|
|
||||||
defaultProviderURL,
|
|
||||||
setDefaultProviderURL,
|
|
||||||
defaultProviderPrefix,
|
|
||||||
setDefaultProviderPrefix,
|
|
||||||
defaultProviderIcon,
|
|
||||||
setDefaultProviderIcon,
|
|
||||||
timeFormat,
|
|
||||||
setTimeFormat,
|
|
||||||
currentUser,
|
|
||||||
setCurrentUser,
|
|
||||||
currentLocation,
|
|
||||||
setCurrentLocation,
|
|
||||||
textShadowStyle,
|
textShadowStyle,
|
||||||
largeTextShadowStyle,
|
largeTextShadowStyle,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -15,14 +15,7 @@ import {
|
|||||||
} from './components';
|
} from './components';
|
||||||
|
|
||||||
export function Homepage() {
|
export function Homepage() {
|
||||||
const {
|
const { isMobile, settings, updateSetting } = useCommonHooks();
|
||||||
appFilter,
|
|
||||||
bookmarkFilter,
|
|
||||||
isMobile,
|
|
||||||
setCurrentUser,
|
|
||||||
currentLocation,
|
|
||||||
setCurrentLocation,
|
|
||||||
} = useCommonHooks();
|
|
||||||
const dateOptions: Intl.DateTimeFormatOptions = isMobile
|
const dateOptions: Intl.DateTimeFormatOptions = isMobile
|
||||||
? {}
|
? {}
|
||||||
: {
|
: {
|
||||||
@@ -34,7 +27,7 @@ export function Homepage() {
|
|||||||
|
|
||||||
const date = new Date().toLocaleDateString('en-US', dateOptions);
|
const date = new Date().toLocaleDateString('en-US', dateOptions);
|
||||||
|
|
||||||
const { data: personalData, isFetched: personalIsFetched } = useQueryAPI({
|
const { data: personalData } = useQueryAPI({
|
||||||
endpoint: 'api/personalData',
|
endpoint: 'api/personalData',
|
||||||
});
|
});
|
||||||
const { data: messageData } = useQueryAPI({
|
const { data: messageData } = useQueryAPI({
|
||||||
@@ -44,8 +37,8 @@ export function Homepage() {
|
|||||||
address: personalData?.[0]?.physicalAddress,
|
address: personalData?.[0]?.physicalAddress,
|
||||||
});
|
});
|
||||||
const { data: meteoWeather } = useOpenMeteoAPI({
|
const { data: meteoWeather } = useOpenMeteoAPI({
|
||||||
lat: weatherMetadata?.[0].lat ?? currentLocation.lat,
|
lat: weatherMetadata?.[0].lat ?? settings.lat,
|
||||||
lon: weatherMetadata?.[0].lon ?? currentLocation.lon,
|
lon: weatherMetadata?.[0].lon ?? settings.lon,
|
||||||
});
|
});
|
||||||
|
|
||||||
const personal: PersonalData = personalData?.[0];
|
const personal: PersonalData = personalData?.[0];
|
||||||
@@ -59,11 +52,6 @@ export function Homepage() {
|
|||||||
const [weatherModalOpened, { open: openWeatherModal, close: closeWeatherModal }] =
|
const [weatherModalOpened, { open: openWeatherModal, close: closeWeatherModal }] =
|
||||||
useDisclosure(false);
|
useDisclosure(false);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (personalData && personalIsFetched) {
|
|
||||||
setCurrentUser(personalData[0]);
|
|
||||||
}
|
|
||||||
}, [personalData, personalIsFetched]);
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (personal) {
|
if (personal) {
|
||||||
setDisplayedGreeting(() => {
|
setDisplayedGreeting(() => {
|
||||||
@@ -87,21 +75,23 @@ export function Homepage() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (meteoWeather) {
|
if (meteoWeather) {
|
||||||
setMeteoCurrent(meteoWeather);
|
setMeteoCurrent(meteoWeather);
|
||||||
setCurrentLocation({
|
updateSetting('lat', weatherMetadata?.[0].lat);
|
||||||
lat: weatherMetadata?.[0].lat,
|
updateSetting('lon', weatherMetadata?.[0].lon);
|
||||||
lon: weatherMetadata?.[0].lon,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}, [meteoWeather]);
|
}, [meteoWeather]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
gap={0}
|
gap={0}
|
||||||
h={appFilter.length > 0 || bookmarkFilter.length > 0 ? undefined : '100%'}
|
h={
|
||||||
|
settings.appFilter.length > 0 || settings.bookmarkFilter.length > 0
|
||||||
|
? undefined
|
||||||
|
: '100%'
|
||||||
|
}
|
||||||
className={stackClasses.containerStack}
|
className={stackClasses.containerStack}
|
||||||
justify='center'
|
justify='center'
|
||||||
>
|
>
|
||||||
{appFilter.length > 0 || bookmarkFilter.length > 0 ? (
|
{settings.appFilter.length > 0 || settings.bookmarkFilter.length > 0 ? (
|
||||||
<>
|
<>
|
||||||
<Search
|
<Search
|
||||||
current={meteoCurrent}
|
current={meteoCurrent}
|
||||||
@@ -120,8 +110,8 @@ export function Homepage() {
|
|||||||
current={meteoCurrent}
|
current={meteoCurrent}
|
||||||
openWeatherModal={openWeatherModal}
|
openWeatherModal={openWeatherModal}
|
||||||
/>
|
/>
|
||||||
<Applications contentType={appFilter} />
|
<Applications contentType={settings.appFilter} />
|
||||||
<Bookmarks contentType={bookmarkFilter} />
|
<Bookmarks contentType={settings.bookmarkFilter} />
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<Box h={'100%'} w={'100%'}>
|
<Box h={'100%'} w={'100%'}>
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ export function Applications({ contentType }: { contentType: string[] }) {
|
|||||||
const { data: applicationData } = useQueryAPI({
|
const { data: applicationData } = useQueryAPI({
|
||||||
endpoint: 'api/enabledApplications',
|
endpoint: 'api/enabledApplications',
|
||||||
});
|
});
|
||||||
const { appSort, appDensity, appScale, theme, textShadowStyle } = useCommonHooks();
|
const { settings, theme, textShadowStyle } = useCommonHooks();
|
||||||
const applications: Application[] = applicationData
|
const applications: Application[] = applicationData
|
||||||
?.sort((a: Application, b: Application) => {
|
?.sort((a: Application, b: Application) => {
|
||||||
switch (appSort) {
|
switch (settings.appSort) {
|
||||||
case 'A>Z':
|
case 'A>Z':
|
||||||
return a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase() ? 1 : -1;
|
return a.name.toLocaleLowerCase() > b.name.toLocaleLowerCase() ? 1 : -1;
|
||||||
case 'Z>A':
|
case 'Z>A':
|
||||||
@@ -54,7 +54,7 @@ export function Applications({ contentType }: { contentType: string[] }) {
|
|||||||
style={{
|
style={{
|
||||||
gap: '.25rem',
|
gap: '.25rem',
|
||||||
display: 'grid',
|
display: 'grid',
|
||||||
gridTemplateColumns: `repeat(${appDensity}, 1fr)`,
|
gridTemplateColumns: `repeat(${settings.appDensity}, 1fr)`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{applications?.map((application: Application) => {
|
{applications?.map((application: Application) => {
|
||||||
@@ -65,7 +65,7 @@ export function Applications({ contentType }: { contentType: string[] }) {
|
|||||||
url={application.url}
|
url={application.url}
|
||||||
icon={application.icon}
|
icon={application.icon}
|
||||||
enabled={application.enabled}
|
enabled={application.enabled}
|
||||||
scale={appScale}
|
scale={settings.appScale}
|
||||||
linksActive
|
linksActive
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -11,15 +11,14 @@ export function Bookmarks({ contentType }: { contentType: string[] }) {
|
|||||||
const { data: groupData, isFetched: groupsIsFetched } = useQueryAPI({
|
const { data: groupData, isFetched: groupsIsFetched } = useQueryAPI({
|
||||||
endpoint: 'api/bookmarkCategories',
|
endpoint: 'api/bookmarkCategories',
|
||||||
});
|
});
|
||||||
const { bookmarkSort, bookmarkDensity, bookmarkScale, theme, textShadowStyle } =
|
const { settings, theme, textShadowStyle } = useCommonHooks();
|
||||||
useCommonHooks();
|
|
||||||
const groupList: BookmarkGroup[] = groupData?.map((category: BookmarkGroup) => {
|
const groupList: BookmarkGroup[] = groupData?.map((category: BookmarkGroup) => {
|
||||||
return category;
|
return category;
|
||||||
});
|
});
|
||||||
const bookmarks: Bookmark[] = bookmarkData || [];
|
const bookmarks: Bookmark[] = bookmarkData || [];
|
||||||
const groups: BookmarkGroup[] = groupList
|
const groups: BookmarkGroup[] = groupList
|
||||||
?.toSorted((a: BookmarkGroup, b: BookmarkGroup) => {
|
?.toSorted((a: BookmarkGroup, b: BookmarkGroup) => {
|
||||||
switch (bookmarkSort) {
|
switch (settings.bookmarkSort) {
|
||||||
case 'A>Z':
|
case 'A>Z':
|
||||||
return a.categoryName.toLocaleLowerCase() > b.categoryName.toLocaleLowerCase()
|
return a.categoryName.toLocaleLowerCase() > b.categoryName.toLocaleLowerCase()
|
||||||
? 1
|
? 1
|
||||||
@@ -71,7 +70,7 @@ export function Bookmarks({ contentType }: { contentType: string[] }) {
|
|||||||
style={{
|
style={{
|
||||||
display: 'grid',
|
display: 'grid',
|
||||||
gridRowGap: '0px',
|
gridRowGap: '0px',
|
||||||
gridTemplateColumns: `repeat(${bookmarkDensity}, 1fr)`,
|
gridTemplateColumns: `repeat(${settings.bookmarkDensity}, 1fr)`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{groups
|
{groups
|
||||||
@@ -88,7 +87,7 @@ export function Bookmarks({ contentType }: { contentType: string[] }) {
|
|||||||
(bookmark: Bookmark) =>
|
(bookmark: Bookmark) =>
|
||||||
bookmark.category === category.categoryName,
|
bookmark.category === category.categoryName,
|
||||||
)}
|
)}
|
||||||
bookmarkScale={bookmarkScale}
|
bookmarkScale={settings.bookmarkScale}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -18,13 +18,12 @@ export function Header({
|
|||||||
const [time, setTime] = useState(new Date());
|
const [time, setTime] = useState(new Date());
|
||||||
const {
|
const {
|
||||||
isMobile,
|
isMobile,
|
||||||
currentUser,
|
|
||||||
fixDigits,
|
fixDigits,
|
||||||
theme,
|
theme,
|
||||||
textShadowStyle,
|
textShadowStyle,
|
||||||
largeTextShadowStyle,
|
largeTextShadowStyle,
|
||||||
timeFormat,
|
settings,
|
||||||
setTimeFormat,
|
updateSetting,
|
||||||
} = useCommonHooks();
|
} = useCommonHooks();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -51,12 +50,12 @@ export function Header({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{greet
|
{greet
|
||||||
?.replace('$firstName', currentUser.firstName)
|
?.replace('$firstName', settings.firstName)
|
||||||
.replace('$lastName', currentUser.lastName)
|
.replace('$lastName', settings.lastName)
|
||||||
.replace('$nickname', currentUser.nickname)
|
.replace('$nickname', settings.nickname)
|
||||||
.replace('$^firstName', currentUser.firstName.toUpperCase())
|
.replace('$^firstName', settings.firstName.toUpperCase())
|
||||||
.replace('$^lastName', currentUser.lastName.toUpperCase())
|
.replace('$^lastName', settings.lastName.toUpperCase())
|
||||||
.replace('$^nickname', currentUser.nickname?.toUpperCase())}
|
.replace('$^nickname', settings.nickname?.toUpperCase())}
|
||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
<Stack
|
<Stack
|
||||||
@@ -123,10 +122,12 @@ export function Header({
|
|||||||
textShadow: theme.textShadowsEnabled ? textShadowStyle : undefined,
|
textShadow: theme.textShadowsEnabled ? textShadowStyle : undefined,
|
||||||
}}
|
}}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
timeFormat === '12h' ? setTimeFormat('24h') : setTimeFormat('12h')
|
settings.timeFormat === '12h'
|
||||||
|
? updateSetting('timeFormat', '24h')
|
||||||
|
: updateSetting('timeFormat', '12h')
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{timeFormat === '12h'
|
{settings.timeFormat === '12h'
|
||||||
? `${
|
? `${
|
||||||
time.getHours() === 0
|
time.getHours() === 0
|
||||||
? 12
|
? 12
|
||||||
|
|||||||
@@ -13,13 +13,12 @@ export function LargeHeader({
|
|||||||
const [time, setTime] = useState(new Date());
|
const [time, setTime] = useState(new Date());
|
||||||
const {
|
const {
|
||||||
isMobile,
|
isMobile,
|
||||||
currentUser,
|
|
||||||
fixDigits,
|
fixDigits,
|
||||||
theme,
|
theme,
|
||||||
textShadowStyle,
|
textShadowStyle,
|
||||||
largeTextShadowStyle,
|
largeTextShadowStyle,
|
||||||
timeFormat,
|
settings,
|
||||||
setTimeFormat,
|
updateSetting,
|
||||||
} = useCommonHooks();
|
} = useCommonHooks();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -40,12 +39,12 @@ export function LargeHeader({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{greet
|
{greet
|
||||||
?.replace('$firstName', currentUser.firstName)
|
?.replace('$firstName', settings.firstName)
|
||||||
.replace('$lastName', currentUser.lastName)
|
.replace('$lastName', settings.lastName)
|
||||||
.replace('$nickname', currentUser.nickname)
|
.replace('$nickname', settings.nickname)
|
||||||
.replace('$^firstName', currentUser.firstName.toUpperCase())
|
.replace('$^firstName', settings.firstName.toUpperCase())
|
||||||
.replace('$^lastName', currentUser.lastName.toUpperCase())
|
.replace('$^lastName', settings.lastName.toUpperCase())
|
||||||
.replace('$^nickname', currentUser.nickname?.toUpperCase())}
|
.replace('$^nickname', settings.nickname?.toUpperCase())}
|
||||||
</Text>
|
</Text>
|
||||||
<Text
|
<Text
|
||||||
fz={'2.25rem'}
|
fz={'2.25rem'}
|
||||||
@@ -69,10 +68,12 @@ export function LargeHeader({
|
|||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
}}
|
}}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
timeFormat === '12h' ? setTimeFormat('24h') : setTimeFormat('12h')
|
settings.timeFormat === '12h'
|
||||||
|
? updateSetting('timeFormat', '24h')
|
||||||
|
: updateSetting('timeFormat', '12h')
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{timeFormat === '12h'
|
{settings.timeFormat === '12h'
|
||||||
? `${
|
? `${
|
||||||
time.getHours() === 0
|
time.getHours() === 0
|
||||||
? 12
|
? 12
|
||||||
|
|||||||
@@ -63,14 +63,8 @@ export function Search({
|
|||||||
setProviderIcon,
|
setProviderIcon,
|
||||||
searchValue,
|
searchValue,
|
||||||
setSearchValue,
|
setSearchValue,
|
||||||
defaultProviderURL,
|
settings,
|
||||||
setDefaultProviderURL,
|
updateSetting,
|
||||||
defaultProviderLabel,
|
|
||||||
setDefaultProviderLabel,
|
|
||||||
defaultProviderPrefix,
|
|
||||||
setDefaultProviderPrefix,
|
|
||||||
defaultProviderIcon,
|
|
||||||
setDefaultProviderIcon,
|
|
||||||
} = useCommonHooks();
|
} = useCommonHooks();
|
||||||
const { ref, height } = useElementSize();
|
const { ref, height } = useElementSize();
|
||||||
const { mutateAsync } = useMutationAPI();
|
const { mutateAsync } = useMutationAPI();
|
||||||
@@ -146,8 +140,8 @@ export function Search({
|
|||||||
setSearchValue('');
|
setSearchValue('');
|
||||||
setListIndex(-1);
|
setListIndex(-1);
|
||||||
setHistoryMultiplier(1);
|
setHistoryMultiplier(1);
|
||||||
setProviderLabel(defaultProviderLabel);
|
setProviderLabel(settings.defaultProviderLabel);
|
||||||
setProviderURL(defaultProviderURL);
|
setProviderURL(settings.defaultProviderURL);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleGuacamoleClientLaunchItem = ({ option }: { option: any }) => {
|
const handleGuacamoleClientLaunchItem = ({ option }: { option: any }) => {
|
||||||
@@ -176,8 +170,12 @@ export function Search({
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
endpoint: searchEndpoint,
|
endpoint: searchEndpoint,
|
||||||
body: { prefix: providerPrefix, provider: providerLabel, searchTerm: subtext },
|
body: { prefix: providerPrefix, provider: providerLabel, searchTerm: subtext },
|
||||||
}).then(() => {
|
})
|
||||||
|
.then(() => {
|
||||||
open(`${providerURL}${subtext}`, '_self');
|
open(`${providerURL}${subtext}`, '_self');
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
} else if (providerLabel === 'Show weather') {
|
} else if (providerLabel === 'Show weather') {
|
||||||
setSearchValue('');
|
setSearchValue('');
|
||||||
@@ -211,8 +209,12 @@ export function Search({
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
endpoint: searchEndpoint,
|
endpoint: searchEndpoint,
|
||||||
body: { prefix: providerPrefix, provider: providerLabel, searchTerm: subtext },
|
body: { prefix: providerPrefix, provider: providerLabel, searchTerm: subtext },
|
||||||
}).then(() => {
|
})
|
||||||
|
.then(() => {
|
||||||
open(`${providerURL}${subtext}`, '_self');
|
open(`${providerURL}${subtext}`, '_self');
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
open(`${providerURL}${subtext}`, '_self');
|
open(`${providerURL}${subtext}`, '_self');
|
||||||
@@ -372,10 +374,10 @@ export function Search({
|
|||||||
setProviderIcon('');
|
setProviderIcon('');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setProviderLabel(defaultProviderLabel);
|
setProviderLabel(settings.defaultProviderLabel);
|
||||||
setProviderURL(defaultProviderURL);
|
setProviderURL(settings.defaultProviderURL);
|
||||||
setProviderPrefix(defaultProviderPrefix);
|
setProviderPrefix(settings.defaultProviderPrefix);
|
||||||
setProviderIcon(defaultProviderIcon);
|
setProviderIcon(settings.defaultProviderIcon);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -460,12 +462,16 @@ export function Search({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (defaultProviderData && defaultProviderDataIsFetched) {
|
if (defaultProviderData && defaultProviderDataIsFetched) {
|
||||||
setDefaultProviderURL(
|
updateSetting(
|
||||||
|
'defaultProviderURL',
|
||||||
defaultProviderData[0]?.url ?? 'https://www.google.com/search?q=',
|
defaultProviderData[0]?.url ?? 'https://www.google.com/search?q=',
|
||||||
);
|
);
|
||||||
setDefaultProviderPrefix(defaultProviderData[0]?.prefix ?? '/g');
|
updateSetting('defaultProviderPrefix', defaultProviderData[0]?.prefix ?? '/g');
|
||||||
setDefaultProviderLabel(defaultProviderData[0]?.name ?? 'Google Search');
|
updateSetting('defaultProviderIcon', defaultProviderData[0]?.icon ?? 'FaGoogle');
|
||||||
setDefaultProviderIcon(defaultProviderData[0]?.icon ?? 'FaGoogle');
|
updateSetting(
|
||||||
|
'defaultProviderLabel',
|
||||||
|
defaultProviderData[0]?.name ?? 'Google Search',
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}, [defaultProviderData, defaultProviderDataIsFetched]);
|
}, [defaultProviderData, defaultProviderDataIsFetched]);
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,11 @@ export default function RenderItem({
|
|||||||
setHistoryMultiplier: React.Dispatch<React.SetStateAction<number>>;
|
setHistoryMultiplier: React.Dispatch<React.SetStateAction<number>>;
|
||||||
searchEndpoint: string;
|
searchEndpoint: string;
|
||||||
}) {
|
}) {
|
||||||
const { defaultProviderURL } = useCommonHooks();
|
const { settings } = useCommonHooks();
|
||||||
const handleSearchHistoryItem = ({ option }: { option: SearchHistoryItem }) => {
|
const handleSearchHistoryItem = ({ option }: { option: SearchHistoryItem }) => {
|
||||||
const url =
|
const url =
|
||||||
providers.find((provider: Provider) => provider.prefix === option.prefix)?.url ??
|
providers.find((provider: Provider) => provider.prefix === option.prefix)?.url ??
|
||||||
defaultProviderURL;
|
settings.defaultProviderURL;
|
||||||
open(`${url}${option.searchTerm}`, '_self');
|
open(`${url}${option.searchTerm}`, '_self');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -130,6 +130,8 @@ function SearchSelectItem({
|
|||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
endpoint: searchEndpoint,
|
endpoint: searchEndpoint,
|
||||||
body: { id: item.option.id },
|
body: { id: item.option.id },
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -33,26 +33,7 @@ export function SettingsButton({ openProviderModal }: { openProviderModal: () =>
|
|||||||
const [selectedClient, setSelectedClient] = useState<WolClient>(wolClientData?.[0]);
|
const [selectedClient, setSelectedClient] = useState<WolClient>(wolClientData?.[0]);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const {
|
const { theme, isMobile, settings } = useCommonHooks();
|
||||||
theme,
|
|
||||||
isMobile,
|
|
||||||
appFilter,
|
|
||||||
setAppFilter,
|
|
||||||
appSort,
|
|
||||||
setAppSort,
|
|
||||||
appDensity,
|
|
||||||
setAppDensity,
|
|
||||||
appScale,
|
|
||||||
setAppScale,
|
|
||||||
bookmarkSort,
|
|
||||||
setBookmarkSort,
|
|
||||||
bookmarkFilter,
|
|
||||||
setBookmarkFilter,
|
|
||||||
bookmarkDensity,
|
|
||||||
setBookmarkDensity,
|
|
||||||
bookmarkScale,
|
|
||||||
setBookmarkScale,
|
|
||||||
} = useCommonHooks();
|
|
||||||
|
|
||||||
const handleWakeRequest = () => {
|
const handleWakeRequest = () => {
|
||||||
mutateAsync({
|
mutateAsync({
|
||||||
@@ -123,26 +104,18 @@ export function SettingsButton({ openProviderModal }: { openProviderModal: () =>
|
|||||||
<SettingsCard
|
<SettingsCard
|
||||||
categories={categories}
|
categories={categories}
|
||||||
sectionTitle={'Applications'}
|
sectionTitle={'Applications'}
|
||||||
filter={appFilter}
|
filter={settings.appFilter}
|
||||||
setFilter={setAppFilter}
|
sort={settings.appSort}
|
||||||
sort={appSort}
|
density={settings.appDensity}
|
||||||
setSort={setAppSort}
|
scale={settings.appScale}
|
||||||
density={appDensity}
|
|
||||||
setDensity={setAppDensity}
|
|
||||||
scale={appScale}
|
|
||||||
setScale={setAppScale}
|
|
||||||
/>
|
/>
|
||||||
<SettingsCard
|
<SettingsCard
|
||||||
categories={categories}
|
categories={categories}
|
||||||
sectionTitle={'Bookmarks'}
|
sectionTitle={'Bookmarks'}
|
||||||
filter={bookmarkFilter}
|
filter={settings.bookmarkFilter}
|
||||||
setFilter={setBookmarkFilter}
|
sort={settings.bookmarkSort}
|
||||||
sort={bookmarkSort}
|
density={settings.bookmarkDensity}
|
||||||
setSort={setBookmarkSort}
|
scale={settings.bookmarkScale}
|
||||||
density={bookmarkDensity}
|
|
||||||
setDensity={setBookmarkDensity}
|
|
||||||
scale={bookmarkScale}
|
|
||||||
setScale={setBookmarkScale}
|
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Group>
|
</Group>
|
||||||
|
|||||||
@@ -14,26 +14,18 @@ function SettingsCard({
|
|||||||
categories,
|
categories,
|
||||||
sectionTitle,
|
sectionTitle,
|
||||||
filter,
|
filter,
|
||||||
setFilter,
|
|
||||||
sort,
|
sort,
|
||||||
setSort,
|
|
||||||
density,
|
density,
|
||||||
setDensity,
|
|
||||||
scale,
|
scale,
|
||||||
setScale,
|
|
||||||
}: {
|
}: {
|
||||||
categories: ComboboxItem[];
|
categories: ComboboxItem[];
|
||||||
sectionTitle: string;
|
sectionTitle: string;
|
||||||
filter: any;
|
filter: any;
|
||||||
setFilter: any;
|
|
||||||
sort: any;
|
sort: any;
|
||||||
setSort: any;
|
|
||||||
density: any;
|
density: any;
|
||||||
setDensity: any;
|
|
||||||
scale: any;
|
scale: any;
|
||||||
setScale: any;
|
|
||||||
}) {
|
}) {
|
||||||
const { theme } = useCommonHooks();
|
const { theme, updateSetting } = useCommonHooks();
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
gap={0}
|
gap={0}
|
||||||
@@ -70,11 +62,23 @@ function SettingsCard({
|
|||||||
className={sliderClasses.default}
|
className={sliderClasses.default}
|
||||||
classNames={sliderClasses}
|
classNames={sliderClasses}
|
||||||
value={density}
|
value={density}
|
||||||
onChange={(value) => setDensity(value)}
|
onChange={(value) => {
|
||||||
|
if (sectionTitle === 'Applications') {
|
||||||
|
updateSetting('appDensity', value);
|
||||||
|
} else if (sectionTitle === 'Bookmarks') {
|
||||||
|
updateSetting('bookmarkDensity', value);
|
||||||
|
}
|
||||||
|
}}
|
||||||
min={1}
|
min={1}
|
||||||
max={16}
|
max={16}
|
||||||
marks={[{ value: 6, label: 'Default' }]}
|
marks={[{ value: 6, label: 'Default' }]}
|
||||||
onDoubleClick={() => setDensity(6)}
|
onDoubleClick={() => {
|
||||||
|
if (sectionTitle === 'Applications') {
|
||||||
|
updateSetting('appDensity', 6);
|
||||||
|
} else if (sectionTitle === 'Bookmarks') {
|
||||||
|
updateSetting('bookmarkDensity', 6);
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
{scale !== undefined && (
|
{scale !== undefined && (
|
||||||
@@ -86,12 +90,24 @@ function SettingsCard({
|
|||||||
className={sliderClasses.default}
|
className={sliderClasses.default}
|
||||||
classNames={sliderClasses}
|
classNames={sliderClasses}
|
||||||
value={scale}
|
value={scale}
|
||||||
onChange={(value) => setScale(value)}
|
onChange={(value) => {
|
||||||
|
if (sectionTitle === 'Applications') {
|
||||||
|
updateSetting('appScale', value);
|
||||||
|
} else if (sectionTitle === 'Bookmarks') {
|
||||||
|
updateSetting('bookmarkScale', value);
|
||||||
|
}
|
||||||
|
}}
|
||||||
step={0.1}
|
step={0.1}
|
||||||
min={0.2}
|
min={0.2}
|
||||||
max={3}
|
max={3}
|
||||||
marks={[{ value: 1, label: 'Default' }]}
|
marks={[{ value: 1, label: 'Default' }]}
|
||||||
onDoubleClick={() => setScale(1)}
|
onDoubleClick={() => {
|
||||||
|
if (sectionTitle === 'Applications') {
|
||||||
|
updateSetting('appScale', 1);
|
||||||
|
} else if (sectionTitle === 'Bookmarks') {
|
||||||
|
updateSetting('bookmarkScale', 1);
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
)}
|
)}
|
||||||
@@ -113,7 +129,11 @@ function SettingsCard({
|
|||||||
}
|
}
|
||||||
defaultValue={filter}
|
defaultValue={filter}
|
||||||
onChange={(data: string[]) => {
|
onChange={(data: string[]) => {
|
||||||
setFilter(data);
|
if (sectionTitle === 'Applications') {
|
||||||
|
updateSetting('appFilter', data);
|
||||||
|
} else if (sectionTitle === 'Bookmarks') {
|
||||||
|
updateSetting('bookmarkFilter', data);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
classNames={multiSelectClasses}
|
classNames={multiSelectClasses}
|
||||||
comboboxProps={{
|
comboboxProps={{
|
||||||
@@ -147,7 +167,11 @@ function SettingsCard({
|
|||||||
position: 'top',
|
position: 'top',
|
||||||
}}
|
}}
|
||||||
onChange={(_value, option: ComboboxItem) => {
|
onChange={(_value, option: ComboboxItem) => {
|
||||||
setSort(option.value);
|
if (sectionTitle === 'Applications') {
|
||||||
|
updateSetting('appSort', option.value);
|
||||||
|
} else if (sectionTitle === 'Bookmarks') {
|
||||||
|
updateSetting('bookmarkSort', option.value);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
labelProps={{ top: 8 }}
|
labelProps={{ top: 8 }}
|
||||||
styles={
|
styles={
|
||||||
|
|||||||
@@ -31,16 +31,8 @@ function ThemingCard({ wolEnabled }: { wolEnabled: number }) {
|
|||||||
});
|
});
|
||||||
const allThemes: Theme[] = allThemeData || [];
|
const allThemes: Theme[] = allThemeData || [];
|
||||||
|
|
||||||
const {
|
const { isMobile, handleThemeChange, theme, settings, updateSetting } =
|
||||||
isMobile,
|
useCommonHooks();
|
||||||
currentTheme,
|
|
||||||
setCurrentTheme,
|
|
||||||
setThemeName,
|
|
||||||
handleThemeChange,
|
|
||||||
theme,
|
|
||||||
currentThemePlaylist,
|
|
||||||
setCurrentThemePlaylist,
|
|
||||||
} = useCommonHooks();
|
|
||||||
|
|
||||||
const [current, setCurrent] = useState<string>(theme.name);
|
const [current, setCurrent] = useState<string>(theme.name);
|
||||||
|
|
||||||
@@ -128,11 +120,11 @@ function ThemingCard({ wolEnabled }: { wolEnabled: number }) {
|
|||||||
borderRadius: '50%',
|
borderRadius: '50%',
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
disabled={currentThemePlaylist === 'Time of Day' || isAnimating}
|
disabled={settings.currentThemePlaylist === 'Time of Day' || isAnimating}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const themeList = JSON.parse(
|
const themeList = JSON.parse(
|
||||||
themePlaylistData?.find(
|
themePlaylistData?.find(
|
||||||
(t: ThemePlaylist) => t?.name === currentThemePlaylist,
|
(t: ThemePlaylist) => t?.name === settings.currentThemePlaylist,
|
||||||
)?.themeList ?? '[]',
|
)?.themeList ?? '[]',
|
||||||
);
|
);
|
||||||
if (themeList.length > 0) {
|
if (themeList.length > 0) {
|
||||||
@@ -140,16 +132,16 @@ function ThemingCard({ wolEnabled }: { wolEnabled: number }) {
|
|||||||
themeList.includes(t.id),
|
themeList.includes(t.id),
|
||||||
);
|
);
|
||||||
handleThemeChange(filteredThemes, false);
|
handleThemeChange(filteredThemes, false);
|
||||||
} else if (currentThemePlaylist === 'All') {
|
} else if (settings.currentThemePlaylist === 'All') {
|
||||||
handleThemeChange(allThemes, true);
|
handleThemeChange(allThemes, true);
|
||||||
} else if (currentThemePlaylist === 'Backgrounds') {
|
} else if (settings.currentThemePlaylist === 'Backgrounds') {
|
||||||
handleThemeChange(
|
handleThemeChange(
|
||||||
allThemes.filter(
|
allThemes.filter(
|
||||||
(a: any) => !a.backgroundImage.toLowerCase().includes('none'),
|
(a: any) => !a.backgroundImage.toLowerCase().includes('none'),
|
||||||
),
|
),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
} else if (currentThemePlaylist === 'No Backgrounds') {
|
} else if (settings.currentThemePlaylist === 'No Backgrounds') {
|
||||||
handleThemeChange(
|
handleThemeChange(
|
||||||
allThemes.filter((a: any) =>
|
allThemes.filter((a: any) =>
|
||||||
a.backgroundImage.toLowerCase().includes('none'),
|
a.backgroundImage.toLowerCase().includes('none'),
|
||||||
@@ -169,7 +161,7 @@ function ThemingCard({ wolEnabled }: { wolEnabled: number }) {
|
|||||||
placeholder='Pick a playlist...'
|
placeholder='Pick a playlist...'
|
||||||
mb={'.25rem'}
|
mb={'.25rem'}
|
||||||
ml={'.25rem'}
|
ml={'.25rem'}
|
||||||
value={currentThemePlaylist}
|
value={settings.currentThemePlaylist}
|
||||||
data={[
|
data={[
|
||||||
{ value: 'All', label: 'All' },
|
{ value: 'All', label: 'All' },
|
||||||
{
|
{
|
||||||
@@ -226,20 +218,21 @@ function ThemingCard({ wolEnabled }: { wolEnabled: number }) {
|
|||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
onChange={(_value, option: ComboboxItem) => {
|
onChange={(_value, option: ComboboxItem) => {
|
||||||
setCurrentThemePlaylist(option.value);
|
updateSetting('currentThemePlaylist', option.value);
|
||||||
if (option.value === 'Time of Day') {
|
if (option.value === 'Time of Day') {
|
||||||
const themeList = JSON.parse(
|
const themeList = JSON.parse(
|
||||||
themePlaylistData.find((t: ThemePlaylist) => t.name === 'Time of Day')
|
themePlaylistData.find((t: ThemePlaylist) => t.name === 'Time of Day')
|
||||||
.themeList,
|
.themeList,
|
||||||
);
|
);
|
||||||
setThemeName(
|
updateSetting(
|
||||||
|
'theme',
|
||||||
allThemeData.find(
|
allThemeData.find(
|
||||||
(t: Theme) =>
|
(t: Theme) =>
|
||||||
t.id === Number(themeList[Math.floor(new Date().getHours() / 6)]),
|
t.id === Number(themeList[Math.floor(new Date().getHours() / 6)]),
|
||||||
).name,
|
).name,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
setThemeName('random');
|
updateSetting('theme', 'random');
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -252,12 +245,12 @@ function ThemingCard({ wolEnabled }: { wolEnabled: number }) {
|
|||||||
<ActionIcon
|
<ActionIcon
|
||||||
className={actionIconClasses.menuActions}
|
className={actionIconClasses.menuActions}
|
||||||
classNames={actionIconClasses}
|
classNames={actionIconClasses}
|
||||||
disabled={currentThemePlaylist === 'Time of Day' || isAnimating}
|
disabled={settings.currentThemePlaylist === 'Time of Day' || isAnimating}
|
||||||
h={40}
|
h={40}
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: 'transparent',
|
backgroundColor: 'transparent',
|
||||||
color:
|
color:
|
||||||
currentTheme === 'random'
|
settings.theme === 'random'
|
||||||
? 'var(--mantine-color-accent-0)'
|
? 'var(--mantine-color-accent-0)'
|
||||||
: 'var(--mantine-color-primary-0)',
|
: 'var(--mantine-color-primary-0)',
|
||||||
borderTopRightRadius: 0,
|
borderTopRightRadius: 0,
|
||||||
@@ -271,7 +264,7 @@ function ThemingCard({ wolEnabled }: { wolEnabled: number }) {
|
|||||||
styles={{
|
styles={{
|
||||||
icon: {
|
icon: {
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
currentTheme === 'random'
|
settings.theme === 'random'
|
||||||
? `${theme?.searchColor === theme?.primaryColor ? theme.searchColor?.substring(0, 7) : theme.primaryColor?.substring(0, 7)}88`
|
? `${theme?.searchColor === theme?.primaryColor ? theme.searchColor?.substring(0, 7) : theme.primaryColor?.substring(0, 7)}88`
|
||||||
: 'transparent',
|
: 'transparent',
|
||||||
width: 'fit-content',
|
width: 'fit-content',
|
||||||
@@ -284,8 +277,8 @@ function ThemingCard({ wolEnabled }: { wolEnabled: number }) {
|
|||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setCurrentTheme(currentTheme === 'random' ? theme.name : 'random');
|
updateSetting('theme', 'random');
|
||||||
setCurrentThemePlaylist('All');
|
updateSetting('currentThemePlaylist', 'All');
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<FiShuffle size={20} />
|
<FiShuffle size={20} />
|
||||||
|
|||||||
@@ -128,10 +128,12 @@ export function Applications() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (applicationList.length > 0 && applicationList !== applications) {
|
if (applicationList.length > 0 && applicationList !== applications) {
|
||||||
void mutateAsync({
|
mutateAsync({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
endpoint: appsOrderEndpoint,
|
endpoint: appsOrderEndpoint,
|
||||||
body: applicationList,
|
body: applicationList,
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [applicationList]);
|
}, [applicationList]);
|
||||||
|
|||||||
@@ -38,7 +38,13 @@ function DebouncedApplication({
|
|||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (debounced && Object.keys(debounced).length > 0) {
|
if (debounced && Object.keys(debounced).length > 0) {
|
||||||
mutateAsync({ method: 'PATCH', endpoint: 'api/applications', body: debounced });
|
mutateAsync({
|
||||||
|
method: 'PATCH',
|
||||||
|
endpoint: 'api/applications',
|
||||||
|
body: debounced,
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, [debounced]);
|
}, [debounced]);
|
||||||
|
|
||||||
|
|||||||
@@ -142,10 +142,12 @@ export function Bookmarks() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (groupList.length > 0 && groupList !== groups) {
|
if (groupList.length > 0 && groupList !== groups) {
|
||||||
void mutateAsync({
|
mutateAsync({
|
||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
endpoint: 'api/bookmarkCategoryOrder',
|
endpoint: 'api/bookmarkCategoryOrder',
|
||||||
body: groupList,
|
body: groupList,
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [groupList]);
|
}, [groupList]);
|
||||||
@@ -160,13 +162,15 @@ export function Bookmarks() {
|
|||||||
body={
|
body={
|
||||||
<form
|
<form
|
||||||
onSubmit={form.onSubmit((values) => {
|
onSubmit={form.onSubmit((values) => {
|
||||||
void mutateAsync({
|
mutateAsync({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
endpoint: categoriesEndpoint,
|
endpoint: categoriesEndpoint,
|
||||||
body: {
|
body: {
|
||||||
...values,
|
...values,
|
||||||
categoryIndex: groups.length,
|
categoryIndex: groups.length,
|
||||||
},
|
},
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
handleClose();
|
handleClose();
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -33,7 +33,11 @@ function DebouncedBookmarkItem({
|
|||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (debounced && Object.keys(debounced).length) {
|
if (debounced && Object.keys(debounced).length) {
|
||||||
mutateAsync({ method: 'PATCH', endpoint: 'api/bookmarks', body: debounced });
|
mutateAsync({ method: 'PATCH', endpoint: 'api/bookmarks', body: debounced }).catch(
|
||||||
|
(error) => {
|
||||||
|
console.error(error);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}, [debounced]);
|
}, [debounced]);
|
||||||
|
|
||||||
|
|||||||
@@ -94,6 +94,8 @@ function DebouncedGroupSettingsItem({
|
|||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
endpoint: 'api/bookmarkCategories',
|
endpoint: 'api/bookmarkCategories',
|
||||||
body: debounced,
|
body: debounced,
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
setUpdate(undefined);
|
setUpdate(undefined);
|
||||||
}
|
}
|
||||||
@@ -107,7 +109,13 @@ function DebouncedGroupSettingsItem({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (bookmarkList && bookmarkList !== bookmarks) {
|
if (bookmarkList && bookmarkList !== bookmarks) {
|
||||||
mutateAsync({ method: 'PATCH', endpoint: 'api/bookmarkOrder', body: bookmarkList });
|
mutateAsync({
|
||||||
|
method: 'PATCH',
|
||||||
|
endpoint: 'api/bookmarkOrder',
|
||||||
|
body: bookmarkList,
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, [bookmarkList]);
|
}, [bookmarkList]);
|
||||||
|
|
||||||
@@ -351,6 +359,8 @@ function DebouncedGroupSettingsItem({
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
endpoint: 'api/bookmarks',
|
endpoint: 'api/bookmarks',
|
||||||
body: { ...values, index: bookmarks.length },
|
body: { ...values, index: bookmarks.length },
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
setPopoverOpened(false);
|
setPopoverOpened(false);
|
||||||
form.reset();
|
form.reset();
|
||||||
|
|||||||
@@ -47,7 +47,13 @@ function DebouncedGuacamoleClient({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (debounced && Object.keys(debounced).length) {
|
if (debounced && Object.keys(debounced).length) {
|
||||||
mutateAsync({ method: 'PATCH', endpoint: 'api/guacamoleClients', body: debounced });
|
mutateAsync({
|
||||||
|
method: 'PATCH',
|
||||||
|
endpoint: 'api/guacamoleClients',
|
||||||
|
body: debounced,
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, [debounced]);
|
}, [debounced]);
|
||||||
|
|
||||||
|
|||||||
@@ -108,10 +108,12 @@ export function GuacamoleClients() {
|
|||||||
body={
|
body={
|
||||||
<form
|
<form
|
||||||
onSubmit={form.onSubmit((values) => {
|
onSubmit={form.onSubmit((values) => {
|
||||||
void mutateAsync({
|
mutateAsync({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
body: { ...values, enabled: 1 },
|
body: { ...values, enabled: 1 },
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
handleClose();
|
handleClose();
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -71,7 +71,11 @@ export function Messages() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (Object.keys(debounced).length) {
|
if (Object.keys(debounced).length) {
|
||||||
void mutateAsync({ method: 'PATCH', endpoint: endpoint, body: debounced });
|
mutateAsync({ method: 'PATCH', endpoint: endpoint, body: debounced }).catch(
|
||||||
|
(error) => {
|
||||||
|
console.error(error);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}, [debounced]);
|
}, [debounced]);
|
||||||
|
|
||||||
@@ -116,10 +120,12 @@ export function Messages() {
|
|||||||
body={
|
body={
|
||||||
<form
|
<form
|
||||||
onSubmit={form.onSubmit((values) => {
|
onSubmit={form.onSubmit((values) => {
|
||||||
void mutateAsync({
|
mutateAsync({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
body: { message: values.message },
|
body: { message: values.message },
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
handleClose();
|
handleClose();
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -37,7 +37,11 @@ export function Personalization() {
|
|||||||
const { isMobile, theme } = useCommonHooks();
|
const { isMobile, theme } = useCommonHooks();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (debounced && Object.keys(debounced).length) {
|
if (debounced && Object.keys(debounced).length) {
|
||||||
void mutateAsync({ method: 'PATCH', endpoint: endpoint, body: debounced });
|
mutateAsync({ method: 'PATCH', endpoint: endpoint, body: debounced }).catch(
|
||||||
|
(error) => {
|
||||||
|
console.error(error);
|
||||||
|
},
|
||||||
|
);
|
||||||
setUpdate(undefined);
|
setUpdate(undefined);
|
||||||
}
|
}
|
||||||
}, [debounced]);
|
}, [debounced]);
|
||||||
|
|||||||
@@ -40,7 +40,11 @@ function DebouncedSearchProvider({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (debounced && Object.keys(debounced).length) {
|
if (debounced && Object.keys(debounced).length) {
|
||||||
mutateAsync({ method: 'PATCH', endpoint: 'api/providers', body: debounced });
|
mutateAsync({ method: 'PATCH', endpoint: 'api/providers', body: debounced }).catch(
|
||||||
|
(error) => {
|
||||||
|
console.error(error);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}, [debounced]);
|
}, [debounced]);
|
||||||
|
|
||||||
|
|||||||
@@ -116,10 +116,12 @@ export function SearchProviders() {
|
|||||||
body={
|
body={
|
||||||
<form
|
<form
|
||||||
onSubmit={form.onSubmit((values) => {
|
onSubmit={form.onSubmit((values) => {
|
||||||
void mutateAsync({
|
mutateAsync({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
body: values,
|
body: values,
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
handleClose();
|
handleClose();
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -59,6 +59,8 @@ export function DeleteBackground({
|
|||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
endpoint: 'api/backgrounds',
|
endpoint: 'api/backgrounds',
|
||||||
body: { fileName },
|
body: { fileName },
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ export function EditBackground({
|
|||||||
fileName.length,
|
fileName.length,
|
||||||
)}`,
|
)}`,
|
||||||
},
|
},
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
mutateAsync({
|
mutateAsync({
|
||||||
@@ -81,6 +83,8 @@ export function EditBackground({
|
|||||||
fileName,
|
fileName,
|
||||||
newFileName: rename,
|
newFileName: rename,
|
||||||
},
|
},
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
handleEditBackgroundModalClose();
|
handleEditBackgroundModalClose();
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export function ThemePlaylists() {
|
|||||||
const [opened, { open, close }] = useDisclosure(false);
|
const [opened, { open, close }] = useDisclosure(false);
|
||||||
const [selectedPlaylist, setSelectedPlaylist] =
|
const [selectedPlaylist, setSelectedPlaylist] =
|
||||||
useState<ThemePlaylist>(defaultPlaylist);
|
useState<ThemePlaylist>(defaultPlaylist);
|
||||||
const { currentThemePlaylist, theme, isMobile } = useCommonHooks();
|
const { settings, theme, isMobile } = useCommonHooks();
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
const handleOpen = useCallback(
|
const handleOpen = useCallback(
|
||||||
@@ -58,10 +58,12 @@ export function ThemePlaylists() {
|
|||||||
}, [close]);
|
}, [close]);
|
||||||
|
|
||||||
const handleSavePlaylist = useCallback(() => {
|
const handleSavePlaylist = useCallback(() => {
|
||||||
void mutateAsync({
|
mutateAsync({
|
||||||
method: selectedPlaylist?.id === undefined ? 'POST' : 'PATCH',
|
method: selectedPlaylist?.id === undefined ? 'POST' : 'PATCH',
|
||||||
endpoint: themePlaylistsEndpoint,
|
endpoint: themePlaylistsEndpoint,
|
||||||
body: selectedPlaylist ?? {},
|
body: selectedPlaylist ?? {},
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
close();
|
close();
|
||||||
}, [selectedPlaylist, mutateAsync, themePlaylistsEndpoint, close]);
|
}, [selectedPlaylist, mutateAsync, themePlaylistsEndpoint, close]);
|
||||||
@@ -189,7 +191,7 @@ export function ThemePlaylists() {
|
|||||||
</Text>
|
</Text>
|
||||||
<Group>
|
<Group>
|
||||||
<Group pos={'relative'}>
|
<Group pos={'relative'}>
|
||||||
{'All' === currentThemePlaylist && (
|
{'All' === settings.currentThemePlaylist && (
|
||||||
<FiChevronRight
|
<FiChevronRight
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
@@ -210,7 +212,7 @@ export function ThemePlaylists() {
|
|||||||
/>
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
<Group pos={'relative'}>
|
<Group pos={'relative'}>
|
||||||
{'Backgrounds' === currentThemePlaylist && (
|
{'Backgrounds' === settings.currentThemePlaylist && (
|
||||||
<FiChevronRight
|
<FiChevronRight
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
@@ -234,7 +236,7 @@ export function ThemePlaylists() {
|
|||||||
/>
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
<Group pos={'relative'}>
|
<Group pos={'relative'}>
|
||||||
{'No Backgrounds' === currentThemePlaylist && (
|
{'No Backgrounds' === settings.currentThemePlaylist && (
|
||||||
<FiChevronRight
|
<FiChevronRight
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
@@ -258,7 +260,7 @@ export function ThemePlaylists() {
|
|||||||
/>
|
/>
|
||||||
</Group>
|
</Group>
|
||||||
<Group pos={'relative'}>
|
<Group pos={'relative'}>
|
||||||
{'Time of Day' === currentThemePlaylist && (
|
{'Time of Day' === settings.currentThemePlaylist && (
|
||||||
<FiChevronRight
|
<FiChevronRight
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
@@ -311,7 +313,7 @@ export function ThemePlaylists() {
|
|||||||
.map((cardPlaylist: ThemePlaylist) => {
|
.map((cardPlaylist: ThemePlaylist) => {
|
||||||
return (
|
return (
|
||||||
<Group key={cardPlaylist.name} pos={'relative'}>
|
<Group key={cardPlaylist.name} pos={'relative'}>
|
||||||
{cardPlaylist.name === currentThemePlaylist && (
|
{cardPlaylist.name === settings.currentThemePlaylist && (
|
||||||
<FiChevronRight
|
<FiChevronRight
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export function ThemePlaylistCard({
|
|||||||
allThemes: Theme[];
|
allThemes: Theme[];
|
||||||
}) {
|
}) {
|
||||||
const [hover, setHover] = useState(false);
|
const [hover, setHover] = useState(false);
|
||||||
const { setThemeName, setCurrentThemePlaylist, handleDelete } = useCommonHooks();
|
const { updateSetting, handleDelete } = useCommonHooks();
|
||||||
const defaultLists = ['All', 'Backgrounds', 'No Backgrounds'];
|
const defaultLists = ['All', 'Backgrounds', 'No Backgrounds'];
|
||||||
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
||||||
const themeList = JSON.parse(
|
const themeList = JSON.parse(
|
||||||
@@ -117,8 +117,8 @@ export function ThemePlaylistCard({
|
|||||||
border: 'solid var(--mantine-color-border-0)',
|
border: 'solid var(--mantine-color-border-0)',
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setCurrentThemePlaylist(cardPlaylist.name);
|
updateSetting('currentThemePlaylist', cardPlaylist.name);
|
||||||
setThemeName('random');
|
updateSetting('theme', 'random');
|
||||||
}}
|
}}
|
||||||
disabled={themeList.length === 0}
|
disabled={themeList.length === 0}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ export function ThemePlaylistStack({
|
|||||||
setPressed(true);
|
setPressed(true);
|
||||||
});
|
});
|
||||||
const [hover, setHover] = useState(false);
|
const [hover, setHover] = useState(false);
|
||||||
const { setThemeName, setCurrentThemePlaylist, handleDelete, currentUser } =
|
const { settings, updateSetting, handleDelete } = useCommonHooks();
|
||||||
useCommonHooks();
|
|
||||||
const [indexOffset, setIndexOffset] = useState(0);
|
const [indexOffset, setIndexOffset] = useState(0);
|
||||||
const [movingIndex, setMovingIndex] = useState(0);
|
const [movingIndex, setMovingIndex] = useState(0);
|
||||||
const missingTheme = {
|
const missingTheme = {
|
||||||
@@ -41,7 +40,7 @@ export function ThemePlaylistStack({
|
|||||||
randomEnabled: 1,
|
randomEnabled: 1,
|
||||||
textShadowsEnabled: 0,
|
textShadowsEnabled: 0,
|
||||||
appShadowsEnabled: 0,
|
appShadowsEnabled: 0,
|
||||||
themeFont: currentUser.defaultFont,
|
themeFont: settings.defaultFont,
|
||||||
};
|
};
|
||||||
const [topTheme, setTopTheme] = useState<Theme>(missingTheme);
|
const [topTheme, setTopTheme] = useState<Theme>(missingTheme);
|
||||||
const defaultLists = ['All', 'Backgrounds', 'No Backgrounds'];
|
const defaultLists = ['All', 'Backgrounds', 'No Backgrounds'];
|
||||||
@@ -156,8 +155,8 @@ export function ThemePlaylistStack({
|
|||||||
borderRadius: '100%',
|
borderRadius: '100%',
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setCurrentThemePlaylist(cardPlaylist.name);
|
updateSetting('currentThemePlaylist', cardPlaylist.name);
|
||||||
setThemeName('random');
|
updateSetting('theme', 'random');
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{modalOpened && (
|
{modalOpened && (
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ export function ThemeCard({
|
|||||||
}) {
|
}) {
|
||||||
const { hovered, ref: hoverRef } = useHover();
|
const { hovered, ref: hoverRef } = useHover();
|
||||||
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
const [modalOpened, { open: openModal, close: closeModal }] = useDisclosure(false);
|
||||||
const { currentTheme, setCurrentTheme, setCurrentThemePlaylist, handleDelete } =
|
const { settings, updateSetting, handleDelete } = useCommonHooks();
|
||||||
useCommonHooks();
|
|
||||||
const [hoverPreview, setHoverPreview] = useDebouncedState(false, 1000);
|
const [hoverPreview, setHoverPreview] = useDebouncedState(false, 1000);
|
||||||
const [transition, setTransition] = useDebouncedState(false, 200);
|
const [transition, setTransition] = useDebouncedState(false, 200);
|
||||||
|
|
||||||
@@ -113,7 +112,7 @@ export function ThemeCard({
|
|||||||
<Button
|
<Button
|
||||||
w={'275px'}
|
w={'275px'}
|
||||||
h={'115px'}
|
h={'115px'}
|
||||||
disabled={currentTheme === 'random'}
|
disabled={settings.theme === 'random'}
|
||||||
style={{
|
style={{
|
||||||
backgroundImage:
|
backgroundImage:
|
||||||
cardTheme?.backgroundImage?.toLocaleLowerCase() === 'none'
|
cardTheme?.backgroundImage?.toLocaleLowerCase() === 'none'
|
||||||
@@ -137,12 +136,12 @@ export function ThemeCard({
|
|||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (enabled !== false) {
|
if (enabled !== false) {
|
||||||
setCurrentTheme(cardTheme.name);
|
updateSetting('theme', cardTheme.name);
|
||||||
setCurrentThemePlaylist('All');
|
updateSetting('currentThemePlaylist', 'All');
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{hovered && enabled && currentTheme !== 'random' && (
|
{hovered && enabled && settings.theme !== 'random' && (
|
||||||
<Overlay
|
<Overlay
|
||||||
style={{
|
style={{
|
||||||
opacity: !hoverPreview || transition ? 0.5 : 0,
|
opacity: !hoverPreview || transition ? 0.5 : 0,
|
||||||
|
|||||||
@@ -29,14 +29,13 @@ export function ThemeManagementPill({
|
|||||||
transition: boolean;
|
transition: boolean;
|
||||||
setTransition: (transition: boolean) => void;
|
setTransition: (transition: boolean) => void;
|
||||||
}) {
|
}) {
|
||||||
const { currentTheme, currentThemePlaylist, handleThemeChange, theme } =
|
const { settings, handleThemeChange, theme } = useCommonHooks();
|
||||||
useCommonHooks();
|
|
||||||
const [shiftEdit, setShiftEdit] = useState<number>(0);
|
const [shiftEdit, setShiftEdit] = useState<number>(0);
|
||||||
const [shiftShuffle, setShiftShuffle] = useState<number>(0);
|
const [shiftShuffle, setShiftShuffle] = useState<number>(0);
|
||||||
const { mutateAsync } = useMutationAPI();
|
const { mutateAsync } = useMutationAPI();
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{currentTheme === 'random' && cardTheme.name === theme.name ? (
|
{settings.theme === 'random' && cardTheme.name === theme.name ? (
|
||||||
<Group>
|
<Group>
|
||||||
<Group
|
<Group
|
||||||
onMouseEnter={() => {
|
onMouseEnter={() => {
|
||||||
@@ -81,16 +80,16 @@ export function ThemeManagementPill({
|
|||||||
setShiftShuffle(0);
|
setShiftShuffle(0);
|
||||||
}}
|
}}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (currentThemePlaylist === 'All') {
|
if (settings.currentThemePlaylist === 'All') {
|
||||||
handleThemeChange(allThemes, false);
|
handleThemeChange(allThemes, false);
|
||||||
} else if (currentThemePlaylist === 'Backgrounds') {
|
} else if (settings.currentThemePlaylist === 'Backgrounds') {
|
||||||
handleThemeChange(
|
handleThemeChange(
|
||||||
allThemes.filter(
|
allThemes.filter(
|
||||||
(a: any) => !a.backgroundImage.toLowerCase().includes('none'),
|
(a: any) => !a.backgroundImage.toLowerCase().includes('none'),
|
||||||
),
|
),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
} else if (currentThemePlaylist === 'No Backgrounds') {
|
} else if (settings.currentThemePlaylist === 'No Backgrounds') {
|
||||||
handleThemeChange(
|
handleThemeChange(
|
||||||
allThemes.filter((a: any) =>
|
allThemes.filter((a: any) =>
|
||||||
a.backgroundImage.toLowerCase().includes('none'),
|
a.backgroundImage.toLowerCase().includes('none'),
|
||||||
@@ -100,7 +99,7 @@ export function ThemeManagementPill({
|
|||||||
} else {
|
} else {
|
||||||
const themeList = JSON.parse(
|
const themeList = JSON.parse(
|
||||||
themePlaylists?.find(
|
themePlaylists?.find(
|
||||||
(t: ThemePlaylist) => t?.name === currentThemePlaylist,
|
(t: ThemePlaylist) => t?.name === settings.currentThemePlaylist,
|
||||||
)?.themeList ?? '[]',
|
)?.themeList ?? '[]',
|
||||||
);
|
);
|
||||||
const filteredThemes = allThemes.filter((t: Theme) =>
|
const filteredThemes = allThemes.filter((t: Theme) =>
|
||||||
@@ -203,6 +202,8 @@ export function ThemeManagementPill({
|
|||||||
method: 'PATCH',
|
method: 'PATCH',
|
||||||
endpoint: 'api/themes',
|
endpoint: 'api/themes',
|
||||||
body: { ...cardTheme, randomEnabled: !cardTheme.randomEnabled },
|
body: { ...cardTheme, randomEnabled: !cardTheme.randomEnabled },
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export function ThemeModal({
|
|||||||
themePlaylists: ThemePlaylist[];
|
themePlaylists: ThemePlaylist[];
|
||||||
}) {
|
}) {
|
||||||
const themesEndpoint = 'api/themes';
|
const themesEndpoint = 'api/themes';
|
||||||
const { currentUser, isMobile } = useCommonHooks();
|
const { settings, isMobile } = useCommonHooks();
|
||||||
const [defaultTheme, setDefaultTheme] = useState<Theme>({ ...selectedTheme });
|
const [defaultTheme, setDefaultTheme] = useState<Theme>({ ...selectedTheme });
|
||||||
const [designerTheme, setDesignerTheme] = useState<Theme>({
|
const [designerTheme, setDesignerTheme] = useState<Theme>({
|
||||||
...selectedTheme,
|
...selectedTheme,
|
||||||
@@ -68,7 +68,7 @@ export function ThemeModal({
|
|||||||
randomEnabled: 1,
|
randomEnabled: 1,
|
||||||
textShadowsEnabled: 0,
|
textShadowsEnabled: 0,
|
||||||
appShadowsEnabled: 0,
|
appShadowsEnabled: 0,
|
||||||
themeFont: currentUser.defaultFont,
|
themeFont: settings.defaultFont,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -77,6 +77,8 @@ export function ThemeModal({
|
|||||||
method: designerTheme?.id === undefined ? 'POST' : 'PATCH',
|
method: designerTheme?.id === undefined ? 'POST' : 'PATCH',
|
||||||
endpoint: themesEndpoint,
|
endpoint: themesEndpoint,
|
||||||
body: designerTheme,
|
body: designerTheme,
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
handleClose();
|
handleClose();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ export default function ThemeChanges({
|
|||||||
designerTheme: Theme;
|
designerTheme: Theme;
|
||||||
setDesignerTheme: (theme: Theme) => void;
|
setDesignerTheme: (theme: Theme) => void;
|
||||||
}) {
|
}) {
|
||||||
const { currentUser, getObjectDiff } = useCommonHooks();
|
const { settings, getObjectDiff } = useCommonHooks();
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
gap={0}
|
gap={0}
|
||||||
@@ -148,7 +148,7 @@ export default function ThemeChanges({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{defaultTheme[key as keyof Theme] ||
|
{defaultTheme[key as keyof Theme] ||
|
||||||
`Default (${currentUser.defaultFont})`}
|
`Default (${settings.defaultFont})`}
|
||||||
</Text>
|
</Text>
|
||||||
<Text>→</Text>
|
<Text>→</Text>
|
||||||
<Text
|
<Text
|
||||||
@@ -158,7 +158,7 @@ export default function ThemeChanges({
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{designerTheme[key as keyof Theme] ||
|
{designerTheme[key as keyof Theme] ||
|
||||||
`Default (${currentUser.defaultFont})`}
|
`Default (${settings.defaultFont})`}
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
)}
|
)}
|
||||||
@@ -197,9 +197,11 @@ export default function ThemeChanges({
|
|||||||
<ColorSwatch
|
<ColorSwatch
|
||||||
h={50}
|
h={50}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigator.clipboard.writeText(
|
navigator.clipboard
|
||||||
defaultTheme[key as keyof Theme] as string,
|
.writeText(defaultTheme[key as keyof Theme] as string)
|
||||||
);
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: (
|
title: (
|
||||||
<Text fw={600} c={'var(--mantine-color-accent-0)'}>
|
<Text fw={600} c={'var(--mantine-color-accent-0)'}>
|
||||||
@@ -250,9 +252,11 @@ export default function ThemeChanges({
|
|||||||
<ColorSwatch
|
<ColorSwatch
|
||||||
h={50}
|
h={50}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigator.clipboard.writeText(
|
navigator.clipboard
|
||||||
defaultTheme[key as keyof Theme] as string,
|
.writeText(defaultTheme[key as keyof Theme] as string)
|
||||||
);
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
notifications.show({
|
notifications.show({
|
||||||
title: (
|
title: (
|
||||||
<Text fw={600} c={'var(--mantine-color-accent-0)'}>
|
<Text fw={600} c={'var(--mantine-color-accent-0)'}>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export function ThemeEditor({
|
|||||||
duplicate: boolean;
|
duplicate: boolean;
|
||||||
setDuplicate: (duplicate: boolean) => void;
|
setDuplicate: (duplicate: boolean) => void;
|
||||||
}) {
|
}) {
|
||||||
const { currentUser, isMobile } = useCommonHooks();
|
const { settings, isMobile } = useCommonHooks();
|
||||||
const [colorId, setColorId] = useState<string>('');
|
const [colorId, setColorId] = useState<string>('');
|
||||||
const [colorValue, setColorValue] = useState('#000000');
|
const [colorValue, setColorValue] = useState('#000000');
|
||||||
const [rgba, setRgba] = useState<{ r: number; g: number; b: number; a?: number }>({
|
const [rgba, setRgba] = useState<{ r: number; g: number; b: number; a?: number }>({
|
||||||
@@ -80,7 +80,7 @@ export function ThemeEditor({
|
|||||||
} else if (font && !customFontEnabled) {
|
} else if (font && !customFontEnabled) {
|
||||||
setDesignerTheme({
|
setDesignerTheme({
|
||||||
...designerTheme,
|
...designerTheme,
|
||||||
themeFont: currentUser.defaultFont || 'Jost',
|
themeFont: settings.defaultFont || 'Jost',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [font]);
|
}, [font]);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { selectClasses, textClasses } from 'styles';
|
|||||||
import type { Theme } from 'types';
|
import type { Theme } from 'types';
|
||||||
|
|
||||||
export function ThemeModalContent({ selectedTheme }: { selectedTheme: Theme }) {
|
export function ThemeModalContent({ selectedTheme }: { selectedTheme: Theme }) {
|
||||||
const { currentUser, textShadowStyle, largeTextShadowStyle } = useCommonHooks();
|
const { settings, textShadowStyle, largeTextShadowStyle } = useCommonHooks();
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
style={{
|
style={{
|
||||||
@@ -31,7 +31,7 @@ export function ThemeModalContent({ selectedTheme }: { selectedTheme: Theme }) {
|
|||||||
'--mantine-color-border-0': selectedTheme?.borderColor,
|
'--mantine-color-border-0': selectedTheme?.borderColor,
|
||||||
'--mantine-color-search-0': selectedTheme?.searchColor,
|
'--mantine-color-search-0': selectedTheme?.searchColor,
|
||||||
transition: 'all 0.2s ease',
|
transition: 'all 0.2s ease',
|
||||||
fontFamily: selectedTheme.themeFont ?? currentUser.defaultFont,
|
fontFamily: selectedTheme.themeFont ?? settings.defaultFont,
|
||||||
}}
|
}}
|
||||||
align='center'
|
align='center'
|
||||||
gap={0}
|
gap={0}
|
||||||
@@ -47,7 +47,7 @@ export function ThemeModalContent({ selectedTheme }: { selectedTheme: Theme }) {
|
|||||||
color: selectedTheme?.primaryColor,
|
color: selectedTheme?.primaryColor,
|
||||||
borderBottom: `thin solid ${selectedTheme?.borderColor}`,
|
borderBottom: `thin solid ${selectedTheme?.borderColor}`,
|
||||||
backgroundColor: `color-mix(in srgb, ${selectedTheme?.searchColor}, transparent 50%)`,
|
backgroundColor: `color-mix(in srgb, ${selectedTheme?.searchColor}, transparent 50%)`,
|
||||||
fontFamily: selectedTheme.themeFont ?? currentUser.defaultFont,
|
fontFamily: selectedTheme.themeFont ?? settings.defaultFont,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
data={[
|
data={[
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export default function ThemeOptions({
|
|||||||
duplicate: boolean;
|
duplicate: boolean;
|
||||||
randomColor: (withAlpha?: boolean) => string;
|
randomColor: (withAlpha?: boolean) => string;
|
||||||
}) {
|
}) {
|
||||||
const { currentUser } = useCommonHooks();
|
const { settings } = useCommonHooks();
|
||||||
return (
|
return (
|
||||||
<Stack h={'100%'} justify='space-between' align='center' gap={4}>
|
<Stack h={'100%'} justify='space-between' align='center' gap={4}>
|
||||||
<Stack w={'100%'} align='center' gap={0} h={'min-content'}>
|
<Stack w={'100%'} align='center' gap={0} h={'min-content'}>
|
||||||
@@ -137,7 +137,7 @@ export default function ThemeOptions({
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
setCustomFontEnabled(!customFontEnabled);
|
setCustomFontEnabled(!customFontEnabled);
|
||||||
setFont(
|
setFont(
|
||||||
customFontEnabled ? currentUser.defaultFont : defaultTheme.themeFont,
|
customFontEnabled ? settings.defaultFont : defaultTheme.themeFont,
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
@@ -163,7 +163,7 @@ export default function ThemeOptions({
|
|||||||
autoLoad
|
autoLoad
|
||||||
defaultValue={
|
defaultValue={
|
||||||
designerTheme.themeFont === null
|
designerTheme.themeFont === null
|
||||||
? currentUser.defaultFont
|
? settings.defaultFont
|
||||||
: designerTheme.themeFont
|
: designerTheme.themeFont
|
||||||
}
|
}
|
||||||
value={(pickerFont: string) => {
|
value={(pickerFont: string) => {
|
||||||
@@ -183,7 +183,7 @@ export default function ThemeOptions({
|
|||||||
color={'red'}
|
color={'red'}
|
||||||
size={32}
|
size={32}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setFont(currentUser.defaultFont);
|
setFont(settings.defaultFont);
|
||||||
setCustomFontEnabled(false);
|
setCustomFontEnabled(false);
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -84,15 +84,7 @@ export function Themes() {
|
|||||||
),
|
),
|
||||||
] as string[];
|
] as string[];
|
||||||
|
|
||||||
const {
|
const { settings, updateSetting, theme, isMobile } = useCommonHooks();
|
||||||
currentTheme,
|
|
||||||
currentUser,
|
|
||||||
setCurrentTheme,
|
|
||||||
theme,
|
|
||||||
isMobile,
|
|
||||||
currentThemePlaylist,
|
|
||||||
setCurrentThemePlaylist,
|
|
||||||
} = useCommonHooks();
|
|
||||||
|
|
||||||
const [selectedTheme, setSelectedTheme] = useState<Theme>({
|
const [selectedTheme, setSelectedTheme] = useState<Theme>({
|
||||||
id: undefined,
|
id: undefined,
|
||||||
@@ -106,7 +98,7 @@ export function Themes() {
|
|||||||
randomEnabled: 1,
|
randomEnabled: 1,
|
||||||
textShadowsEnabled: 0,
|
textShadowsEnabled: 0,
|
||||||
appShadowsEnabled: 0,
|
appShadowsEnabled: 0,
|
||||||
themeFont: currentUser.defaultFont,
|
themeFont: settings.defaultFont,
|
||||||
});
|
});
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [isNew, setIsNew] = useState(false);
|
const [isNew, setIsNew] = useState(false);
|
||||||
@@ -184,7 +176,7 @@ export function Themes() {
|
|||||||
>
|
>
|
||||||
<Overlay
|
<Overlay
|
||||||
display={
|
display={
|
||||||
currentTheme === 'random' && debouncedSearch === '' ? 'flex' : 'none'
|
settings.theme === 'random' && debouncedSearch === '' ? 'flex' : 'none'
|
||||||
}
|
}
|
||||||
blur={5}
|
blur={5}
|
||||||
style={{
|
style={{
|
||||||
@@ -199,7 +191,7 @@ export function Themes() {
|
|||||||
{allThemes?.length > 0 ? (
|
{allThemes?.length > 0 ? (
|
||||||
allThemes.map((cardTheme: Theme) => (
|
allThemes.map((cardTheme: Theme) => (
|
||||||
<Group key={cardTheme.name} pos={'relative'}>
|
<Group key={cardTheme.name} pos={'relative'}>
|
||||||
{cardTheme.name === currentTheme && (
|
{cardTheme.name === settings.theme && (
|
||||||
<FiChevronRight
|
<FiChevronRight
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
@@ -219,11 +211,12 @@ export function Themes() {
|
|||||||
<Box
|
<Box
|
||||||
style={{
|
style={{
|
||||||
zIndex:
|
zIndex:
|
||||||
currentTheme === 'random' &&
|
settings.theme === 'random' &&
|
||||||
(themePlaylists
|
(themePlaylists
|
||||||
.find(
|
.find(
|
||||||
(t: ThemePlaylist) =>
|
(t: ThemePlaylist) =>
|
||||||
t.name.toLowerCase() === currentThemePlaylist.toLowerCase(),
|
t.name.toLowerCase() ===
|
||||||
|
settings.currentThemePlaylist.toLowerCase(),
|
||||||
)
|
)
|
||||||
?.themeList.includes(`${cardTheme.id}`) ||
|
?.themeList.includes(`${cardTheme.id}`) ||
|
||||||
cardTheme.name === theme.name)
|
cardTheme.name === theme.name)
|
||||||
@@ -310,7 +303,9 @@ export function Themes() {
|
|||||||
fontSize: isMobile ? '.8rem' : '1.2rem',
|
fontSize: isMobile ? '.8rem' : '1.2rem',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{currentThemePlaylist === 'All' ? 'All' : currentThemePlaylist}
|
{settings.currentThemePlaylist === 'All'
|
||||||
|
? 'All'
|
||||||
|
: settings.currentThemePlaylist}
|
||||||
</Text>
|
</Text>
|
||||||
</Group>
|
</Group>
|
||||||
<Divider
|
<Divider
|
||||||
@@ -320,13 +315,13 @@ export function Themes() {
|
|||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
if (currentThemePlaylist === 'All') {
|
if (settings.currentThemePlaylist === 'All') {
|
||||||
void navigate(
|
void navigate(
|
||||||
`/${import.meta.env.VITE_BASE_URL}/settings/themePlaylists`,
|
`/${import.meta.env.VITE_BASE_URL}/settings/themePlaylists`,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
setCurrentThemePlaylist('All');
|
updateSetting('currentThemePlaylist', 'All');
|
||||||
setCurrentTheme(theme.name);
|
updateSetting('theme', theme.name);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
@@ -334,7 +329,7 @@ export function Themes() {
|
|||||||
padding: isMobile ? 0 : undefined,
|
padding: isMobile ? 0 : undefined,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{currentThemePlaylist === 'All' ? (
|
{settings.currentThemePlaylist === 'All' ? (
|
||||||
isMobile ? (
|
isMobile ? (
|
||||||
<FiMousePointer />
|
<FiMousePointer />
|
||||||
) : (
|
) : (
|
||||||
@@ -350,11 +345,11 @@ export function Themes() {
|
|||||||
className={toolTipClasses.default}
|
className={toolTipClasses.default}
|
||||||
classNames={toolTipClasses}
|
classNames={toolTipClasses}
|
||||||
label='Shuffle is always on when a playlist is active.'
|
label='Shuffle is always on when a playlist is active.'
|
||||||
disabled={currentThemePlaylist === 'All'}
|
disabled={settings.currentThemePlaylist === 'All'}
|
||||||
>
|
>
|
||||||
<Group>
|
<Group>
|
||||||
<Switch
|
<Switch
|
||||||
disabled={currentThemePlaylist !== 'All'}
|
disabled={settings.currentThemePlaylist !== 'All'}
|
||||||
label={
|
label={
|
||||||
isMobile ? (
|
isMobile ? (
|
||||||
<FaDice size={20} color={'var(--mantine-color-primary-0)'} />
|
<FaDice size={20} color={'var(--mantine-color-primary-0)'} />
|
||||||
@@ -363,10 +358,10 @@ export function Themes() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
labelPosition='left'
|
labelPosition='left'
|
||||||
checked={currentTheme === 'random'}
|
checked={settings.theme === 'random'}
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setCurrentTheme(e.target.checked ? 'random' : theme.name);
|
updateSetting('theme', e.target.checked ? 'random' : theme.name);
|
||||||
setCurrentThemePlaylist('All');
|
updateSetting('currentThemePlaylist', 'All');
|
||||||
}}
|
}}
|
||||||
className={switchClasses.default}
|
className={switchClasses.default}
|
||||||
classNames={switchClasses}
|
classNames={switchClasses}
|
||||||
|
|||||||
@@ -28,7 +28,11 @@ function DebouncedWolClient({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (debounced && Object.keys(debounced).length) {
|
if (debounced && Object.keys(debounced).length) {
|
||||||
mutateAsync({ method: 'PATCH', endpoint: 'api/WolClients', body: debounced });
|
mutateAsync({ method: 'PATCH', endpoint: 'api/WolClients', body: debounced }).catch(
|
||||||
|
(error) => {
|
||||||
|
console.error(error);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}, [debounced]);
|
}, [debounced]);
|
||||||
|
|
||||||
|
|||||||
@@ -99,10 +99,12 @@ export function WolClients() {
|
|||||||
body={
|
body={
|
||||||
<form
|
<form
|
||||||
onSubmit={form.onSubmit((values) => {
|
onSubmit={form.onSubmit((values) => {
|
||||||
void mutateAsync({
|
mutateAsync({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
endpoint: endpoint,
|
endpoint: endpoint,
|
||||||
body: values,
|
body: values,
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
});
|
});
|
||||||
handleClose();
|
handleClose();
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ export type { Message } from './message';
|
|||||||
export type { PersonalData } from './personalData';
|
export type { PersonalData } from './personalData';
|
||||||
export type { Provider } from './provider';
|
export type { Provider } from './provider';
|
||||||
export type { SearchHistoryItem, SearchShortcut } from './search';
|
export type { SearchHistoryItem, SearchShortcut } from './search';
|
||||||
|
export type { Settings } from './settings';
|
||||||
export type { Theme, ThemePlaylist } from './theme';
|
export type { Theme, ThemePlaylist } from './theme';
|
||||||
export { ThemeProperties } from './theme';
|
export { ThemeProperties } from './theme';
|
||||||
export type { User } from './user';
|
export type { User } from './user';
|
||||||
|
|||||||
28
src/types/settings.ts
Normal file
28
src/types/settings.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
export interface Settings {
|
||||||
|
theme: string;
|
||||||
|
appFilter: string[];
|
||||||
|
appSort: string;
|
||||||
|
appDensity: number;
|
||||||
|
appScale: number;
|
||||||
|
bookmarkSort: string;
|
||||||
|
bookmarkFilter: string[];
|
||||||
|
bookmarkDensity: number;
|
||||||
|
bookmarkScale: number;
|
||||||
|
currentThemePlaylist: string;
|
||||||
|
defaultProviderLabel: string;
|
||||||
|
defaultProviderURL: string;
|
||||||
|
defaultProviderPrefix: string;
|
||||||
|
defaultProviderIcon: string;
|
||||||
|
timeFormat: string;
|
||||||
|
firstName: string;
|
||||||
|
lastName: string;
|
||||||
|
email: string;
|
||||||
|
physicalAddress: string;
|
||||||
|
enableWol: number;
|
||||||
|
enableGuacamole: number;
|
||||||
|
guacamoleHost: string;
|
||||||
|
nickname: string;
|
||||||
|
defaultFont: string;
|
||||||
|
lat: number;
|
||||||
|
lon: number;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user