mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 01:23:52 +00:00
This adds a button to call the ServiceWorkerRegistration.update() function. This button will be hidden if there is already an update pending. This also adds a button to restart the app to apply the update. This is nice in case users accidentally close the notification that asks to restart. The about button is moved to the new app group in the setting menu.
27 lines
812 B
TypeScript
27 lines
812 B
TypeScript
// SPDX-License-Identifier: MIT
|
|
// Copyright (c) 2021 The Pybricks Authors
|
|
|
|
import { call, put, takeEvery } from 'typed-redux-saga/macro';
|
|
import {
|
|
AppActionType,
|
|
AppCheckForUpdatesAction,
|
|
AppReloadAction,
|
|
didCheckForUpdate,
|
|
} from '../actions/app';
|
|
|
|
function* reload(action: AppReloadAction): Generator {
|
|
yield* call(() => action.registration.unregister());
|
|
location.reload();
|
|
}
|
|
|
|
function* checkForUpdate(action: AppCheckForUpdatesAction): Generator {
|
|
yield* call(() => action.registration.update());
|
|
const updateFound = action.registration.installing !== null;
|
|
yield* put(didCheckForUpdate(updateFound));
|
|
}
|
|
|
|
export default function* app(): Generator {
|
|
yield* takeEvery(AppActionType.Reload, reload);
|
|
yield* takeEvery(AppActionType.CheckForUpdate, checkForUpdate);
|
|
}
|