openreplay/frontend/app/player/web/storageSelectors.ts
Andrey Babushkin fd5c0c9747
Add lokalisation (#3092)
* applied eslint

* add locales and lint the project

* removed error boundary

* updated locales

* fix min files

* fix locales
2025-03-06 17:43:15 +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 [];
}