From 00f156b139fee6bfffa72f6cd5ffa77dc8c70a43 Mon Sep 17 00:00:00 2001 From: Callum Macdonald Date: Tue, 10 Dec 2024 14:39:55 +0100 Subject: [PATCH] Add a settings slice. --- nr-app/src/redux/slices/settings.slice.ts | 26 +++++++++++++++++++++++ nr-app/src/redux/store.ts | 2 ++ 2 files changed, 28 insertions(+) create mode 100644 nr-app/src/redux/slices/settings.slice.ts diff --git a/nr-app/src/redux/slices/settings.slice.ts b/nr-app/src/redux/slices/settings.slice.ts new file mode 100644 index 0000000..4b787ea --- /dev/null +++ b/nr-app/src/redux/slices/settings.slice.ts @@ -0,0 +1,26 @@ +import { createSlice } from "@reduxjs/toolkit"; + +type SettingsState = { + areTestFeaturesEnabled: boolean; +}; + +const initialState: SettingsState = { + areTestFeaturesEnabled: false, +}; + +export const settingsSlice = createSlice({ + name: "settings", + initialState, + reducers: { + toggleTestFeatures: (state, action) => { + state.areTestFeaturesEnabled = !state.areTestFeaturesEnabled; + }, + }, + selectors: { + selectAreTestFeaturesEnabled: (state) => state.areTestFeaturesEnabled, + }, +}); + +export const settingsActions = settingsSlice.actions; + +export const settingsSelectors = settingsSlice.selectors; diff --git a/nr-app/src/redux/store.ts b/nr-app/src/redux/store.ts index 7bc0d8f..634f718 100644 --- a/nr-app/src/redux/store.ts +++ b/nr-app/src/redux/store.ts @@ -9,6 +9,7 @@ import { eventsSlice } from "./slices/events.slice"; import { mapSlice } from "./slices/map.slice"; import { relaysSlice } from "./slices/relays.slice"; import { keystoreSlice } from "./slices/keystore.slice"; +import { settingsSlice } from "./slices/settings.slice"; const isOnDevice = Platform.OS !== "web"; @@ -21,6 +22,7 @@ const reducer = combineSlices( keystoreSlice, mapSlice, relaysSlice, + settingsSlice, ); export const store = configureStore({