mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 01:23:52 +00:00
make about dialog open/close local
This commit is contained in:
+1
-23
@@ -28,10 +28,6 @@ export enum AppActionType {
|
||||
OpenSettings = 'app.action.openSettings',
|
||||
/** Close settings dialog. */
|
||||
CloseSettings = 'app.action.closeSettings',
|
||||
/** Open about dialog. */
|
||||
OpenAboutDialog = 'app.action.openAboutDialog',
|
||||
/** Close about dialog. */
|
||||
CloseAboutDialog = 'app.action.closeAboutDialog',
|
||||
}
|
||||
|
||||
/** Action that requests the app to reload. */
|
||||
@@ -128,22 +124,6 @@ export function closeSettings(): AppCloseSettingsAction {
|
||||
return { type: AppActionType.CloseSettings };
|
||||
}
|
||||
|
||||
/** Action to open the about dialog. */
|
||||
export type AppOpenAboutDialogAction = Action<AppActionType.OpenAboutDialog>;
|
||||
|
||||
/** Creates an action to open the about dialog. */
|
||||
export function openAboutDialog(): AppOpenAboutDialogAction {
|
||||
return { type: AppActionType.OpenAboutDialog };
|
||||
}
|
||||
|
||||
/** Action to close the about dialog. */
|
||||
export type AppCloseAboutDialogAction = Action<AppActionType.CloseAboutDialog>;
|
||||
|
||||
/** Creates an action to close the about dialog. */
|
||||
export function closeAboutDialog(): AppCloseAboutDialogAction {
|
||||
return { type: AppActionType.CloseAboutDialog };
|
||||
}
|
||||
|
||||
/** common type for all app actions. */
|
||||
export type AppAction =
|
||||
| AppReloadAction
|
||||
@@ -155,6 +135,4 @@ export type AppAction =
|
||||
| AppDidInstallAction
|
||||
| AppDidStartAction
|
||||
| AppOpenSettingsAction
|
||||
| AppCloseSettingsAction
|
||||
| AppOpenAboutDialogAction
|
||||
| AppCloseAboutDialogAction;
|
||||
| AppCloseSettingsAction;
|
||||
|
||||
@@ -6,14 +6,12 @@ import { didSucceed, didUpdate } from '../service-worker/actions';
|
||||
import { BeforeInstallPromptEvent } from '../utils/dom';
|
||||
import {
|
||||
checkForUpdate,
|
||||
closeAboutDialog,
|
||||
closeSettings,
|
||||
didBeforeInstallPrompt,
|
||||
didCheckForUpdate,
|
||||
didInstall,
|
||||
didInstallPrompt,
|
||||
installPrompt,
|
||||
openAboutDialog,
|
||||
openSettings,
|
||||
} from './actions';
|
||||
import reducers from './reducers';
|
||||
@@ -28,7 +26,6 @@ test('initial state', () => {
|
||||
"promptingInstall": false,
|
||||
"readyForOfflineUse": false,
|
||||
"serviceWorker": null,
|
||||
"showAboutDialog": false,
|
||||
"showSettings": false,
|
||||
"updateAvailable": false,
|
||||
}
|
||||
@@ -44,17 +41,6 @@ test('showSettings', () => {
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
test('showAboutDialog', () => {
|
||||
expect(
|
||||
reducers({ showAboutDialog: false } as State, openAboutDialog())
|
||||
.showAboutDialog,
|
||||
).toBe(true);
|
||||
expect(
|
||||
reducers({ showAboutDialog: true } as State, closeAboutDialog())
|
||||
.showAboutDialog,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
test('serviceWorker', () => {
|
||||
const registration = {} as ServiceWorkerRegistration;
|
||||
expect(
|
||||
|
||||
@@ -20,17 +20,6 @@ const showSettings: Reducer<boolean, Action> = (state = false, action) => {
|
||||
}
|
||||
};
|
||||
|
||||
const showAboutDialog: Reducer<boolean, Action> = (state = false, action) => {
|
||||
switch (action.type) {
|
||||
case AppActionType.OpenAboutDialog:
|
||||
return true;
|
||||
case AppActionType.CloseAboutDialog:
|
||||
return false;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
const serviceWorker: Reducer<ServiceWorkerRegistration | null, Action> = (
|
||||
state = null,
|
||||
action,
|
||||
@@ -105,7 +94,6 @@ const readyForOfflineUse: Reducer<boolean, Action> = (state = false, action) =>
|
||||
|
||||
export default combineReducers({
|
||||
showSettings,
|
||||
showAboutDialog,
|
||||
serviceWorker,
|
||||
checkingForUpdate,
|
||||
updateAvailable,
|
||||
|
||||
Reference in New Issue
Block a user