pl-fe: Remove unused action

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-10-20 13:22:50 +02:00
parent 7c2eaf5702
commit 72efcada65
3 changed files with 1 additions and 31 deletions

View File

@ -1,16 +0,0 @@
/** Sets the ServiceWorker updating state. */
const SW_UPDATING = 'SW_UPDATING' as const;
/** Dispatch when the ServiceWorker is being updated to display a loading screen. */
const setSwUpdating = (isUpdating: boolean) => ({
type: SW_UPDATING,
isUpdating,
});
type SwAction = ReturnType<typeof setSwUpdating>;
export {
SW_UPDATING,
setSwUpdating,
type SwAction,
};

View File

@ -1,7 +1,5 @@
import { Record as ImmutableRecord } from 'immutable';
import { SW_UPDATING, setSwUpdating } from 'pl-fe/actions/sw';
import reducer from './meta';
describe('meta reducer', () => {
@ -11,11 +9,4 @@ describe('meta reducer', () => {
expect(result.instance_fetch_failed).toBe(false);
expect(result.swUpdating).toBe(false);
});
describe(SW_UPDATING, () => {
it('sets swUpdating to the provided value', () => {
const result = reducer(undefined, setSwUpdating(true));
expect(result.swUpdating).toBe(true);
});
});
});

View File

@ -1,24 +1,19 @@
import { Record as ImmutableRecord } from 'immutable';
import { INSTANCE_FETCH_FAIL, type InstanceAction } from 'pl-fe/actions/instance';
import { SW_UPDATING, type SwAction } from 'pl-fe/actions/sw';
const ReducerRecord = ImmutableRecord({
/** Whether /api/v1/instance 404'd (and we should display the external auth form). */
instance_fetch_failed: false,
/** Whether the ServiceWorker is currently updating (and we should display a loading screen). */
swUpdating: false,
});
const meta = (state = ReducerRecord(), action: InstanceAction | SwAction) => {
const meta = (state = ReducerRecord(), action: InstanceAction) => {
switch (action.type) {
case INSTANCE_FETCH_FAIL:
if (action.error?.response?.status === 404) {
return state.set('instance_fetch_failed', true);
}
return state;
case SW_UPDATING:
return state.set('swUpdating', action.isUpdating);
default:
return state;
}