Skip to content

A local-first personal finance app

Move loot-core/client/app code over to desktop-client package (#4817)

Joel Jeremy Marquez582bb590972b
diff --git a/packages/desktop-client/src/accounts/accountsSlice.ts b/packages/desktop-client/src/accounts/accountsSlice.ts
index a20c5a9c74..2f3ba99e8a 100644
--- a/packages/desktop-client/src/accounts/accountsSlice.ts
+++ b/packages/desktop-client/src/accounts/accountsSlice.ts
@@ -1,6 +1,5 @@
import { createSlice, type PayloadAction } from '@reduxjs/toolkit';
-import { resetApp } from 'loot-core/client/app/appSlice';
import { addNotification } from 'loot-core/client/notifications/notificationsSlice';
import {
getAccounts,
@@ -19,6 +18,8 @@ import {
type SyncServerPluggyAiAccount,
} from 'loot-core/types/models';
+import { resetApp } from '../app/appSlice';
+
const sliceName = 'account';
type AccountState = {
diff --git a/packages/loot-core/src/client/app/appSlice.ts b/packages/desktop-client/src/app/appSlice.ts
similarity index 88%
rename from packages/loot-core/src/client/app/appSlice.ts
rename to packages/desktop-client/src/app/appSlice.ts
index 6cb0b8ec03..1d96bb4cb8 100644
--- a/packages/loot-core/src/client/app/appSlice.ts
+++ b/packages/desktop-client/src/app/appSlice.ts
@@ -1,19 +1,18 @@
-// This is temporary until we move all loot-core/client over to desktop-client.
-// eslint-disable-next-line no-restricted-imports
-import { syncAccounts } from '@actual-app/web/src/accounts/accountsSlice';
import {
createAction,
createSlice,
type PayloadAction,
} from '@reduxjs/toolkit';
-import { send } from '../../platform/client/fetch';
-import { getUploadError } from '../../shared/errors';
-import { type AccountEntity } from '../../types/models';
-import { type AtLeastOne } from '../../types/util';
-import { pushModal } from '../modals/modalsSlice';
-import { loadPrefs } from '../prefs/prefsSlice';
-import { createAppAsyncThunk } from '../redux';
+import { pushModal } from 'loot-core/client/modals/modalsSlice';
+import { loadPrefs } from 'loot-core/client/prefs/prefsSlice';
+import { createAppAsyncThunk } from 'loot-core/client/redux';
+import { send } from 'loot-core/platform/client/fetch';
+import { getUploadError } from 'loot-core/shared/errors';
+import { type AccountEntity } from 'loot-core/types/models';
+import { type AtLeastOne } from 'loot-core/types/util';
+
+import { syncAccounts } from '../accounts/accountsSlice';
const sliceName = 'app';
diff --git a/packages/desktop-client/src/components/App.tsx b/packages/desktop-client/src/components/App.tsx
index 995dd46b4e..2ad0990253 100644
--- a/packages/desktop-client/src/components/App.tsx
+++ b/packages/desktop-client/src/components/App.tsx
@@ -14,7 +14,6 @@ import { BrowserRouter } from 'react-router-dom';
import { styles } from '@actual-app/components/styles';
import { View } from '@actual-app/components/view';
-import { setAppState, sync } from 'loot-core/client/app/appSlice';
import { closeBudget, loadBudget } from 'loot-core/client/budgets/budgetsSlice';
import { addNotification } from 'loot-core/client/notifications/notificationsSlice';
import * as Platform from 'loot-core/client/platform';
@@ -23,6 +22,7 @@ import { SpreadsheetProvider } from 'loot-core/client/SpreadsheetProvider';
import { signOut } from 'loot-core/client/users/usersSlice';
import { init as initConnection, send } from 'loot-core/platform/client/fetch';
+import { setAppState, sync } from '../app/appSlice';
import { handleGlobalEvents } from '../global-events';
import { setI18NextLanguage } from '../i18n';
import { installPolyfills } from '../polyfills';
diff --git a/packages/desktop-client/src/components/FinancesApp.tsx b/packages/desktop-client/src/components/FinancesApp.tsx
index cf86982b6d..ee0e98bdb0 100644
--- a/packages/desktop-client/src/components/FinancesApp.tsx
+++ b/packages/desktop-client/src/components/FinancesApp.tsx
@@ -13,10 +13,10 @@ import { useResponsive } from '@actual-app/components/hooks/useResponsive';
import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
-import { sync } from 'loot-core/client/app/appSlice';
import { addNotification } from 'loot-core/client/notifications/notificationsSlice';
import * as undo from 'loot-core/platform/client/undo';
+import { sync } from '../app/appSlice';
import { ProtectedRoute } from '../auth/ProtectedRoute';
import { Permissions } from '../auth/types';
import { useSelector, useDispatch } from '../redux';
diff --git a/packages/desktop-client/src/components/Titlebar.tsx b/packages/desktop-client/src/components/Titlebar.tsx
index bdf5db6b80..2460d53355 100644
--- a/packages/desktop-client/src/components/Titlebar.tsx
+++ b/packages/desktop-client/src/components/Titlebar.tsx
@@ -19,7 +19,6 @@ import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { css } from '@emotion/css';
-import { sync } from 'loot-core/client/app/appSlice';
import * as Platform from 'loot-core/client/platform';
import * as queries from 'loot-core/client/queries';
import { listen } from 'loot-core/platform/client/fetch';
@@ -28,6 +27,7 @@ import {
isElectron,
} from 'loot-core/shared/environment';
+import { sync } from '../app/appSlice';
import { useDispatch } from '../redux';
import { AccountSyncCheck } from './accounts/AccountSyncCheck';
diff --git a/packages/desktop-client/src/components/UpdateNotification.tsx b/packages/desktop-client/src/components/UpdateNotification.tsx
index 1252695afa..ae4bb3f0bf 100644
--- a/packages/desktop-client/src/components/UpdateNotification.tsx
+++ b/packages/desktop-client/src/components/UpdateNotification.tsx
@@ -7,8 +7,7 @@ import { Text } from '@actual-app/components/text';
import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
-import { setAppState, updateApp } from 'loot-core/client/app/appSlice';
-
+import { setAppState, updateApp } from '../app/appSlice';
import { useSelector, useDispatch } from '../redux';
import { Link } from './common/Link';
diff --git a/packages/desktop-client/src/components/accounts/Account.tsx b/packages/desktop-client/src/components/accounts/Account.tsx
index 9df7d3766e..ef2b56cf54 100644
--- a/packages/desktop-client/src/components/accounts/Account.tsx
+++ b/packages/desktop-client/src/components/accounts/Account.tsx
@@ -16,7 +16,6 @@ import { debounce } from 'debounce';
import { t } from 'i18next';
import { v4 as uuidv4 } from 'uuid';
-import { syncAndDownload } from 'loot-core/client/app/appSlice';
import { useFilters } from 'loot-core/client/data-hooks/filters';
import {
SchedulesProvider,
@@ -67,6 +66,7 @@ import {
} from 'loot-core/types/models';
import { unlinkAccount } from '../../accounts/accountsSlice';
+import { syncAndDownload } from '../../app/appSlice';
import { useSelector, useDispatch } from '../../redux';
import { type SavedFilter } from '../filters/SavedFilterMenuButton';
import { TransactionList } from '../transactions/TransactionList';
diff --git a/packages/desktop-client/src/components/manager/ManagementApp.tsx b/packages/desktop-client/src/components/manager/ManagementApp.tsx
index b73eb910c6..85a80609d9 100644
--- a/packages/desktop-client/src/components/manager/ManagementApp.tsx
+++ b/packages/desktop-client/src/components/manager/ManagementApp.tsx
@@ -7,9 +7,9 @@ import { theme } from '@actual-app/components/theme';
import { tokens } from '@actual-app/components/tokens';
import { View } from '@actual-app/components/view';
-import { setAppState } from 'loot-core/client/app/appSlice';
import { loggedIn } from 'loot-core/client/users/usersSlice';
+import { setAppState } from '../../app/appSlice';
import { ProtectedRoute } from '../../auth/ProtectedRoute';
import { Permissions } from '../../auth/types';
import { useSelector, useDispatch } from '../../redux';
diff --git a/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx b/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx
index ac9b414a0a..eda1f7cade 100644
--- a/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx
+++ b/packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx
@@ -13,7 +13,6 @@ import { Text } from '@actual-app/components/text';
import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
-import { syncAndDownload } from 'loot-core/client/app/appSlice';
import {
accountSchedulesQuery,
SchedulesProvider,
@@ -41,6 +40,7 @@ import {
type TransactionEntity,
} from 'loot-core/types/models';
+import { syncAndDownload } from '../../../app/appSlice';
import { useSelector, useDispatch } from '../../../redux';
import { MobilePageHeader, Page } from '../../Page';
import { MobileBackButton } from '../MobileBackButton';
diff --git a/packages/desktop-client/src/components/mobile/accounts/Accounts.tsx b/packages/desktop-client/src/components/mobile/accounts/Accounts.tsx
index 1b5674e19d..4d7d4eda7b 100644
--- a/packages/desktop-client/src/components/mobile/accounts/Accounts.tsx
+++ b/packages/desktop-client/src/components/mobile/accounts/Accounts.tsx
@@ -27,12 +27,12 @@ import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { css } from '@emotion/css';
-import { syncAndDownload } from 'loot-core/client/app/appSlice';
import { replaceModal } from 'loot-core/client/modals/modalsSlice';
import * as queries from 'loot-core/client/queries';
import { type AccountEntity } from 'loot-core/types/models';
import { moveAccount } from '../../../accounts/accountsSlice';
+import { syncAndDownload } from '../../../app/appSlice';
import { useDispatch, useSelector } from '../../../redux';
import { makeAmountFullStyle } from '../../budget/util';
import { MobilePageHeader, Page } from '../../Page';
diff --git a/packages/desktop-client/src/components/mobile/budget/index.tsx b/packages/desktop-client/src/components/mobile/budget/index.tsx
index 2bd3a3648c..44d5222a8e 100644
--- a/packages/desktop-client/src/components/mobile/budget/index.tsx
+++ b/packages/desktop-client/src/components/mobile/budget/index.tsx
@@ -5,7 +5,6 @@ import { AnimatedLoading } from '@actual-app/components/icons/AnimatedLoading';
import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
-import { sync } from 'loot-core/client/app/appSlice';
import { collapseModals, pushModal } from 'loot-core/client/modals/modalsSlice';
import {
applyBudgetAction,
@@ -20,6 +19,7 @@ import { useSpreadsheet } from 'loot-core/client/SpreadsheetProvider';
import { send } from 'loot-core/platform/client/fetch';
import * as monthUtils from 'loot-core/shared/months';
+import { sync } from '../../../app/appSlice';
import { useDispatch } from '../../../redux';
import { prewarmMonth } from '../../budget/util';
import { NamespaceContext } from '../../spreadsheet/NamespaceContext';
diff --git a/packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx b/packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx
index c0dc4a4020..9d527ed8e8 100644
--- a/packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx
+++ b/packages/desktop-client/src/components/modals/CreateEncryptionKeyModal.tsx
@@ -14,13 +14,13 @@ import { theme } from '@actual-app/components/theme';
import { View } from '@actual-app/components/view';
import { css } from '@emotion/css';
-import { sync } from 'loot-core/client/app/appSlice';
import { loadAllFiles } from 'loot-core/client/budgets/budgetsSlice';
import { type Modal as ModalType } from 'loot-core/client/modals/modalsSlice';
import { loadGlobalPrefs } from 'loot-core/client/prefs/prefsSlice';
import { send } from 'loot-core/platform/client/fetch';
import { getCreateKeyError } from 'loot-core/shared/errors';
+import { sync } from '../../app/appSlice';
import { useDispatch } from '../../redux';
import { Link } from '../common/Link';
import {
diff --git a/packages/desktop-client/src/components/settings/Reset.tsx b/packages/desktop-client/src/components/settings/Reset.tsx
index d06184b5c5..4b3505c331 100644
--- a/packages/desktop-client/src/components/settings/Reset.tsx
+++ b/packages/desktop-client/src/components/settings/Reset.tsx
@@ -4,9 +4,9 @@ import { Trans } from 'react-i18next';
import { ButtonWithLoading } from '@actual-app/components/button';
import { Text } from '@actual-app/components/text';
-import { resetSync } from 'loot-core/client/app/appSlice';
import { send } from 'loot-core/platform/client/fetch';
+import { resetSync } from '../../app/appSlice';
import { useDispatch } from '../../redux';
import { Setting } from './UI';
diff --git a/packages/desktop-client/src/global-events.ts b/packages/desktop-client/src/global-events.ts
index 3377835f3f..e7aa939c8b 100644
--- a/packages/desktop-client/src/global-events.ts
+++ b/packages/desktop-client/src/global-events.ts
@@ -1,5 +1,4 @@
// @ts-strict-ignore
-import { setAppState } from 'loot-core/client/app/appSlice';
import { closeBudgetUI } from 'loot-core/client/budgets/budgetsSlice';
import {
closeModal,
@@ -21,6 +20,8 @@ import { type AppStore } from 'loot-core/client/store';
import { listen } from 'loot-core/platform/client/fetch';
import * as undo from 'loot-core/platform/client/undo';
+import { setAppState } from './app/appSlice';
+
export function handleGlobalEvents(store: AppStore) {
const unlistenServerError = listen('server-error', () => {
store.dispatch(addGenericErrorNotification());
diff --git a/packages/desktop-client/src/index.tsx b/packages/desktop-client/src/index.tsx
index 24e1c5d9b0..4ff448452f 100644
--- a/packages/desktop-client/src/index.tsx
+++ b/packages/desktop-client/src/index.tsx
@@ -13,7 +13,6 @@ import { Provider } from 'react-redux';
import { bindActionCreators } from '@reduxjs/toolkit';
import { createRoot } from 'react-dom/client';
-import * as appSlice from 'loot-core/client/app/appSlice';
import * as budgetsSlice from 'loot-core/client/budgets/budgetsSlice';
import * as modalsSlice from 'loot-core/client/modals/modalsSlice';
import * as notificationsSlice from 'loot-core/client/notifications/notificationsSlice';
@@ -27,6 +26,7 @@ import { send } from 'loot-core/platform/client/fetch';
import { q } from 'loot-core/shared/query';
import * as accountsSlice from './accounts/accountsSlice';
+import * as appSlice from './app/appSlice';
import { AuthProvider } from './auth/AuthProvider';
// See https://github.com/WICG/focus-visible. Only makes the blue
// focus outline appear from keyboard events.
diff --git a/packages/loot-core/src/client/budgets/budgetsSlice.ts b/packages/loot-core/src/client/budgets/budgetsSlice.ts
index b0d583a7d4..ce7d96ba1b 100644
--- a/packages/loot-core/src/client/budgets/budgetsSlice.ts
+++ b/packages/loot-core/src/client/budgets/budgetsSlice.ts
@@ -1,3 +1,6 @@
+// This is temporary until we move all loot-core/client over to desktop-client.
+// eslint-disable-next-line no-restricted-imports
+import { resetApp, setAppState } from '@actual-app/web/src/app/appSlice';
import { createSlice, type PayloadAction } from '@reduxjs/toolkit';
import { t } from 'i18next';
@@ -7,7 +10,6 @@ import { getDownloadError, getSyncError } from '../../shared/errors';
import { type Budget } from '../../types/budget';
import { type File } from '../../types/file';
import { type Handlers } from '../../types/handlers';
-import { resetApp, setAppState } from '../app/appSlice';
import { closeModal, pushModal } from '../modals/modalsSlice';
import { loadGlobalPrefs, loadPrefs } from '../prefs/prefsSlice';
import { createAppAsyncThunk } from '../redux';
diff --git a/packages/loot-core/src/client/modals/modalsSlice.ts b/packages/loot-core/src/client/modals/modalsSlice.ts
index 8a7f85a86b..e1797bd16e 100644
--- a/packages/loot-core/src/client/modals/modalsSlice.ts
+++ b/packages/loot-core/src/client/modals/modalsSlice.ts
@@ -1,3 +1,6 @@
+// This is temporary until we move all loot-core/client over to desktop-client.
+// eslint-disable-next-line no-restricted-imports
+import { resetApp, setAppState } from '@actual-app/web/src/app/appSlice';
import { createSlice, type PayloadAction } from '@reduxjs/toolkit';
import { send } from '../../platform/client/fetch';
@@ -17,7 +20,6 @@ import {
type NewUserEntity,
type NoteEntity,
} from '../../types/models';
-import { resetApp, setAppState } from '../app/appSlice';
import { createAppAsyncThunk } from '../redux';
import { signOut } from '../users/usersSlice';
diff --git a/packages/loot-core/src/client/notifications/notificationsSlice.ts b/packages/loot-core/src/client/notifications/notificationsSlice.ts
index b5304dbf33..5c8c35bec9 100644
--- a/packages/loot-core/src/client/notifications/notificationsSlice.ts
+++ b/packages/loot-core/src/client/notifications/notificationsSlice.ts
@@ -1,9 +1,10 @@
+// This is temporary until we move all loot-core/client over to desktop-client.
+// eslint-disable-next-line no-restricted-imports
+import { resetApp } from '@actual-app/web/src/app/appSlice';
import { createSlice, type PayloadAction } from '@reduxjs/toolkit';
import { t } from 'i18next';
import { v4 as uuidv4 } from 'uuid';
-import { resetApp } from '../app/appSlice';
-
const sliceName = 'notifications';
export type Notification = {
diff --git a/packages/loot-core/src/client/prefs/prefsSlice.ts b/packages/loot-core/src/client/prefs/prefsSlice.ts
index 736c38e6b0..b127f117b1 100644
--- a/packages/loot-core/src/client/prefs/prefsSlice.ts
+++ b/packages/loot-core/src/client/prefs/prefsSlice.ts
@@ -1,5 +1,8 @@
-// eslint-disable-next-line no-restricted-imports -- fix me -- do not import @actual-app/web in loot-core
+// This is temporary until we move all loot-core/client over to desktop-client.
+/* eslint-disable no-restricted-imports */
+import { resetApp } from '@actual-app/web/src/app/appSlice';
import { setI18NextLanguage } from '@actual-app/web/src/i18n';
+/* eslint-enable no-restricted-imports */
import { createSlice, type PayloadAction } from '@reduxjs/toolkit';
import { send } from '../../platform/client/fetch';
@@ -9,7 +12,6 @@ import {
type MetadataPrefs,
type SyncedPrefs,
} from '../../types/prefs';
-import { resetApp } from '../app/appSlice';
import { closeModal } from '../modals/modalsSlice';
import { createAppAsyncThunk } from '../redux';
diff --git a/packages/loot-core/src/client/queries/queriesSlice.ts b/packages/loot-core/src/client/queries/queriesSlice.ts
index 1a3720ab36..84d2355cad 100644
--- a/packages/loot-core/src/client/queries/queriesSlice.ts
+++ b/packages/loot-core/src/client/queries/queriesSlice.ts
@@ -1,4 +1,7 @@
// @ts-strict-ignore
+// This is temporary until we move all loot-core/client over to desktop-client.
+// eslint-disable-next-line no-restricted-imports
+import { resetApp } from '@actual-app/web/src/app/appSlice';
import { createSlice, type PayloadAction } from '@reduxjs/toolkit';
import { t } from 'i18next';
import memoizeOne from 'memoize-one';
@@ -12,7 +15,6 @@ import {
type AccountEntity,
type PayeeEntity,
} from '../../types/models';
-import { resetApp } from '../app/appSlice';
import {
addGenericErrorNotification,
addNotification,
diff --git a/packages/loot-core/src/client/shared-listeners.ts b/packages/loot-core/src/client/shared-listeners.ts
index 77393e71f4..cda7263ab9 100644
--- a/packages/loot-core/src/client/shared-listeners.ts
+++ b/packages/loot-core/src/client/shared-listeners.ts
@@ -1,9 +1,11 @@
// @ts-strict-ignore
+// This is temporary until we move all loot-core/client over to desktop-client.
+// eslint-disable-next-line no-restricted-imports
+import { resetSync, sync } from '@actual-app/web/src/app/appSlice';
import { t } from 'i18next';
import { listen, send } from '../platform/client/fetch';
-import { resetSync, sync } from './app/appSlice';
import { closeAndDownloadBudget, uploadBudget } from './budgets/budgetsSlice';
import { pushModal } from './modals/modalsSlice';
import {
diff --git a/packages/loot-core/src/client/store/index.ts b/packages/loot-core/src/client/store/index.ts
index 288f4e84b9..60dac062a5 100644
--- a/packages/loot-core/src/client/store/index.ts
+++ b/packages/loot-core/src/client/store/index.ts
@@ -1,9 +1,14 @@
// This is temporary until we move all loot-core/client over to desktop-client.
-// eslint-disable-next-line no-restricted-imports
+/* eslint-disable no-restricted-imports */
import {
name as accountsSliceName,
reducer as accountsSliceReducer,
} from '@actual-app/web/src/accounts/accountsSlice';
+import {
+ name as appSliceName,
+ reducer as appSliceReducer,
+} from '@actual-app/web/src/app/appSlice';
+/* eslint-enable no-restricted-imports */
import {
combineReducers,
configureStore,
@@ -11,10 +16,6 @@ import {
isRejected,
} from '@reduxjs/toolkit';
-import {
- name as appSliceName,
- reducer as appSliceReducer,
-} from '../app/appSlice';
import {
name as budgetsSliceName,
reducer as budgetsSliceReducer,
diff --git a/packages/loot-core/src/client/store/mock.ts b/packages/loot-core/src/client/store/mock.ts
index 851312329c..6552ebf08f 100644
--- a/packages/loot-core/src/client/store/mock.ts
+++ b/packages/loot-core/src/client/store/mock.ts
@@ -1,15 +1,17 @@
// This is temporary until we move all loot-core/client over to desktop-client.
-// eslint-disable-next-line no-restricted-imports
+/* eslint-disable */
import {
name as accountsSliceName,
reducer as accountsSliceReducer,
} from '@actual-app/web/src/accounts/accountsSlice';
-import { configureStore, combineReducers } from '@reduxjs/toolkit';
-
import {
name as appSliceName,
reducer as appSliceReducer,
-} from '../app/appSlice';
+} from '@actual-app/web/src/app/appSlice';
+/* eslint-enable */
+
+import { configureStore, combineReducers } from '@reduxjs/toolkit';
+
import {
name as budgetsSliceName,
reducer as budgetsSliceReducer,
diff --git a/packages/loot-core/src/client/users/usersSlice.ts b/packages/loot-core/src/client/users/usersSlice.ts
index 853df41bd0..3ce10eaa3c 100644
--- a/packages/loot-core/src/client/users/usersSlice.ts
+++ b/packages/loot-core/src/client/users/usersSlice.ts
@@ -1,8 +1,10 @@
+// This is temporary until we move all loot-core/client over to desktop-client.
+// eslint-disable-next-line no-restricted-imports
+import { resetApp } from '@actual-app/web/src/app/appSlice';
import { createSlice, type PayloadAction } from '@reduxjs/toolkit';
import { send } from '../../platform/client/fetch';
import { type Handlers } from '../../types/handlers';
-import { resetApp } from '../app/appSlice';
import { closeBudget, loadAllFiles } from '../budgets/budgetsSlice';
import { loadGlobalPrefs } from '../prefs/prefsSlice';
import { createAppAsyncThunk } from '../redux';
diff --git a/upcoming-release-notes/4817.md b/upcoming-release-notes/4817.md
new file mode 100644
index 0000000000..cce9c8e0a5
--- /dev/null
+++ b/upcoming-release-notes/4817.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [joel-jeremy]
+---
+
+Move loot-core/client/app code over to desktop-client package