From 4d6edf46bd76b999dbd981a6673bebc1452337ad Mon Sep 17 00:00:00 2001 From: Joel Jeremy Marquez Date: Tue, 14 Jan 2025 11:00:10 -0800 Subject: [PATCH] Delete constants --- .../src/client/budgets/budgetsSlice.ts | 6 +++--- packages/loot-core/src/client/constants.ts | 21 ------------------- packages/loot-core/src/client/store/index.ts | 6 ++++-- 3 files changed, 7 insertions(+), 26 deletions(-) delete mode 100644 packages/loot-core/src/client/constants.ts diff --git a/packages/loot-core/src/client/budgets/budgetsSlice.ts b/packages/loot-core/src/client/budgets/budgetsSlice.ts index 5b2fdcc202b..47e72c5c9fe 100644 --- a/packages/loot-core/src/client/budgets/budgetsSlice.ts +++ b/packages/loot-core/src/client/budgets/budgetsSlice.ts @@ -8,11 +8,11 @@ import { type Budget } from '../../types/budget'; import { type File } from '../../types/file'; import { type Handlers } from '../../types/handlers'; import { setAppState } from '../app/appSlice'; -import * as constants from '../constants'; import { closeModal, pushModal } from '../modals/modalsSlice'; import { loadGlobalPrefs, loadPrefs } from '../prefs/prefsSlice'; import { createAppAsyncThunk } from '../redux'; import { signOut } from '../users/usersSlice'; +import { CLOSE_BUDGET } from '../store'; const sliceName = 'budgets'; @@ -104,7 +104,7 @@ export const closeBudget = createAppAsyncThunk( if (prefs && prefs.id) { // This clears out all the app state so the user starts fresh // TODO: Change to use an action once CLOSE_BUDGET is migrated to redux toolkit. - await dispatch({ type: constants.CLOSE_BUDGET }); + await dispatch({ type: CLOSE_BUDGET }); await dispatch(setAppState({ loadingText: t('Closing...') })); await send('close-budget'); @@ -122,7 +122,7 @@ export const closeBudgetUI = createAppAsyncThunk( const prefs = getState().prefs.local; if (prefs && prefs.id) { // TODO: Change to use an action once CLOSE_BUDGET is migrated to redux toolkit. - await dispatch({ type: constants.CLOSE_BUDGET }); + await dispatch({ type: CLOSE_BUDGET }); } }, ); diff --git a/packages/loot-core/src/client/constants.ts b/packages/loot-core/src/client/constants.ts deleted file mode 100644 index c2d2de63323..00000000000 --- a/packages/loot-core/src/client/constants.ts +++ /dev/null @@ -1,21 +0,0 @@ -export const SET_PREFS = 'SET_PREFS'; -export const MERGE_LOCAL_PREFS = 'MERGE_LOCAL_PREFS'; -export const MERGE_GLOBAL_PREFS = 'MERGE_GLOBAL_PREFS'; -export const MERGE_SYNCED_PREFS = 'MERGE_SYNCED_PREFS'; -export const SET_BUDGETS = 'SET_BUDGETS'; -export const SET_REMOTE_FILES = 'SET_REMOTE_FILES'; -export const SET_ALL_FILES = 'SET_ALL_FILES'; -export const CLOSE_BUDGET = 'CLOSE_BUDGET'; -export const SET_APP_STATE = 'SET_APP_STATE'; -export const PUSH_MODAL = 'PUSH_MODAL'; -export const REPLACE_MODAL = 'REPLACE_MODAL'; -export const CLOSE_MODAL = 'CLOSE_MODAL'; -export const COLLAPSE_MODALS = 'COLLAPSE_MODALS'; -export const POP_MODAL = 'POP_MODAL'; -export const ADD_NOTIFICATION = 'ADD_NOTIFICATION'; -export const REMOVE_NOTIFICATION = 'REMOVE_NOTIFICATION'; -export const SET_NOTIFICATION_INSET = 'SET_NOTIFICATION_INSET'; -export const GET_USER_DATA = 'GET_USER_DATA'; -export const SET_ACCOUNTS_SYNCING = 'SET_ACCOUNTS_SYNCING'; -export const ACCOUNT_SYNC_STATUS = 'ACCOUNT_SYNC_STATUS'; -export const SIGN_OUT = 'SIGN_OUT'; diff --git a/packages/loot-core/src/client/store/index.ts b/packages/loot-core/src/client/store/index.ts index 2dbb54ed86b..534eabd06b1 100644 --- a/packages/loot-core/src/client/store/index.ts +++ b/packages/loot-core/src/client/store/index.ts @@ -21,7 +21,6 @@ import { reducer as budgetsSliceReducer, getInitialState as getInitialBudgetsState, } from '../budgets/budgetsSlice'; -import * as constants from '../constants'; import { name as modalsSliceName, reducer as modalsSliceReducer, @@ -58,8 +57,11 @@ const appReducer = combineReducers({ [queriesSliceName]: queriesSliceReducer, [usersSliceName]: usersSliceReducer, }); + +export const CLOSE_BUDGET = 'CLOSE_BUDGET'; + const rootReducer: typeof appReducer = (state, action) => { - if (action.type === constants.CLOSE_BUDGET) { + if (action.type === CLOSE_BUDGET) { // Reset the state and only keep around things intentionally. This // blows away everything else state = {