Front: Use API to get settings
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import { Appearance } from "react-native";
|
||||
import { useSelector } from "react-redux";
|
||||
import { SettingsState } from "../state/SettingsSlice";
|
||||
import { RootState } from "../state/Store";
|
||||
|
||||
const useColorScheme = (): 'light' | 'dark' => {
|
||||
const colorScheme: SettingsState['colorScheme'] = useSelector((state: RootState) => state.settings.settings.colorScheme);
|
||||
const colorScheme = useSelector((state: RootState) => state.settings.local.colorScheme);
|
||||
const systemColorScheme = Appearance.getColorScheme();
|
||||
|
||||
if (colorScheme == 'system') {
|
||||
|
||||
13
front/hooks/userSettings.ts
Normal file
13
front/hooks/userSettings.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { useQuery } from "react-query"
|
||||
import API from "../API"
|
||||
|
||||
const useUserSettings = () => {
|
||||
const queryKey = ['settings'];
|
||||
const settings = useQuery(queryKey, () => API.getUserSettings())
|
||||
const updateSettings = (...params: Parameters<typeof API.updateUserSettings>) => API
|
||||
.updateUserSettings(...params)
|
||||
.then(() => settings.refetch());
|
||||
return { settings, updateSettings }
|
||||
}
|
||||
|
||||
export default useUserSettings;
|
||||
Reference in New Issue
Block a user