diff options
| author | Tobias Järvelöv <tobias.jarvelov@mullvad.net> | 2025-03-18 11:41:44 +0100 |
|---|---|---|
| committer | Tobias Järvelöv <tobias.jarvelov@mullvad.net> | 2025-05-28 10:28:14 +0200 |
| commit | ffa9c6c4c4e20f8f92bb095fc9b9c421fa5242a0 (patch) | |
| tree | b485b2ffce3a4e83d0dc982374a1ce882c913030 /desktop | |
| parent | 8a1a7d8d9b34fcac8e261f457f3e65ce3ac599f0 (diff) | |
| download | mullvadvpn-ffa9c6c4c4e20f8f92bb095fc9b9c421fa5242a0.tar.xz mullvadvpn-ffa9c6c4c4e20f8f92bb095fc9b9c421fa5242a0.zip | |
Add Redux app-upgrade namespace
Diffstat (limited to 'desktop')
3 files changed, 81 insertions, 0 deletions
diff --git a/desktop/packages/mullvad-vpn/src/renderer/redux/app-upgrade/actions.ts b/desktop/packages/mullvad-vpn/src/renderer/redux/app-upgrade/actions.ts new file mode 100644 index 0000000000..b72c434d7d --- /dev/null +++ b/desktop/packages/mullvad-vpn/src/renderer/redux/app-upgrade/actions.ts @@ -0,0 +1,40 @@ +import { AppUpgradeError, AppUpgradeEvent } from '../../../shared/app-upgrade'; + +export type AppUpgradeActionReset = { + type: 'APP_UPGRADE_RESET'; +}; + +export const resetAppUpgrade = (): AppUpgradeActionReset => ({ + type: 'APP_UPGRADE_RESET', +}); + +export type AppUpgradeActionSetError = { + type: 'APP_UPGRADE_SET_ERROR'; + error: AppUpgradeError; +}; + +export const setAppUpgradeError = (error: AppUpgradeError): AppUpgradeActionSetError => ({ + type: 'APP_UPGRADE_SET_ERROR', + error, +}); + +export type AppUpgradeActionSetEvent = { + type: 'APP_UPGRADE_SET_EVENT'; + event: AppUpgradeEvent; +}; + +export const setAppUpgradeEvent = (event: AppUpgradeEvent): AppUpgradeActionSetEvent => ({ + type: 'APP_UPGRADE_SET_EVENT', + event, +}); + +export const appUpgradeActions = { + resetAppUpgrade, + setAppUpgradeError, + setAppUpgradeEvent, +}; + +export type AppUpgradeAction = + | AppUpgradeActionReset + | AppUpgradeActionSetError + | AppUpgradeActionSetEvent; diff --git a/desktop/packages/mullvad-vpn/src/renderer/redux/app-upgrade/reducers.ts b/desktop/packages/mullvad-vpn/src/renderer/redux/app-upgrade/reducers.ts new file mode 100644 index 0000000000..69ad6c2ef7 --- /dev/null +++ b/desktop/packages/mullvad-vpn/src/renderer/redux/app-upgrade/reducers.ts @@ -0,0 +1,36 @@ +import { AppUpgradeError, AppUpgradeEvent } from '../../../shared/app-upgrade'; +import { AppUpgradeAction } from './actions'; + +export interface AppUpgradeReduxState { + error?: AppUpgradeError; + event?: AppUpgradeEvent; +} + +const initialState: AppUpgradeReduxState = { + error: undefined, + event: undefined, +}; + +export function appUpgradeReducer( + state: AppUpgradeReduxState = initialState, + action: AppUpgradeAction, +): AppUpgradeReduxState { + switch (action.type) { + case 'APP_UPGRADE_SET_EVENT': + return { + ...state, + event: action.event, + }; + case 'APP_UPGRADE_SET_ERROR': + return { + ...state, + error: action.error, + }; + case 'APP_UPGRADE_RESET': + return { + ...initialState, + }; + default: + return state; + } +} diff --git a/desktop/packages/mullvad-vpn/src/renderer/redux/store.ts b/desktop/packages/mullvad-vpn/src/renderer/redux/store.ts index a691c7d01f..ae2cc2c9f8 100644 --- a/desktop/packages/mullvad-vpn/src/renderer/redux/store.ts +++ b/desktop/packages/mullvad-vpn/src/renderer/redux/store.ts @@ -3,6 +3,8 @@ import { combineReducers, compose, createStore, Dispatch, StoreEnhancer } from ' import accountActions, { AccountAction } from './account/actions'; import accountReducer, { IAccountReduxState } from './account/reducers'; +import { appUpgradeActions } from './app-upgrade/actions'; +import { appUpgradeReducer, AppUpgradeReduxState } from './app-upgrade/reducers'; import connectionActions, { ConnectionAction } from './connection/actions'; import connectionReducer, { IConnectionReduxState } from './connection/reducers'; import settingsActions, { SettingsAction } from './settings/actions'; @@ -18,6 +20,7 @@ import versionReducer, { IVersionReduxState } from './version/reducers'; export interface IReduxState { account: IAccountReduxState; + appUpgrade: AppUpgradeReduxState; connection: IConnectionReduxState; settings: ISettingsReduxState; support: ISupportReduxState; @@ -40,6 +43,7 @@ export type ReduxDispatch = Dispatch<ReduxAction>; export default function configureStore() { const reducers = { account: accountReducer, + appUpgrade: appUpgradeReducer, connection: connectionReducer, settings: settingsReducer, support: supportReducer, @@ -56,6 +60,7 @@ export default function configureStore() { function composeEnhancers(): StoreEnhancer { const actionCreators = { ...accountActions, + ...appUpgradeActions, ...connectionActions, ...settingsActions, ...supportActions, |
