openreplay/frontend/app/player/web/storageSelectors.ts
Андрей Бабушкин 2b1a9f3378 add locales and lint the project
2025-03-05 16:09:18 +01:00

46 lines
1 KiB
TypeScript

import { State } from './Lists';
export enum StorageType {
REDUX = 'redux',
MOBX = 'mobx',
VUEX = 'vuex',
NGRX = 'ngrx',
ZUSTAND = 'zustand',
NONE = 0,
}
export const STORAGE_TYPES = StorageType; // TODO: update name everywhere
export function selectStorageType(state: State): StorageType {
if (state.reduxList?.length > 0) {
return StorageType.REDUX;
}
if (state.vuexList?.length > 0) {
return StorageType.VUEX;
}
if (state.mobxList?.length > 0) {
return StorageType.MOBX;
}
if (state.ngrxList?.length > 0) {
return StorageType.NGRX;
}
if (state.zustandList?.length > 0) {
return StorageType.ZUSTAND;
}
return StorageType.NONE;
}
export function selectStorageList(state: State) {
const key = selectStorageType(state);
if (key !== StorageType.NONE) {
return state[`${key}List`];
}
return [];
}
export function selectStorageListNow(state: State) {
const key = selectStorageType(state);
if (key !== StorageType.NONE) {
return state[`${key}ListNow`];
}
return [];
}