fix(player):export storage selectors

This commit is contained in:
Alex Kaminskii 2022-11-29 15:20:16 +01:00
parent 6a82d34d8c
commit bb8a0105a1
2 changed files with 49 additions and 4 deletions

View file

@ -1,8 +1,10 @@
export * from './web/assist/AssistManager';
export * from './web/assist/LocalStream';
export * from './web/WebPlayer';
export * from './web/types';
export * from './common/types';
export * from './create';
export * from './web/assist/AssistManager';
export * from './web/assist/LocalStream';
export * from './web/WebPlayer';
export * from './web/storageSelectors';
export * from './web/types';
export type { MarkedTarget } from './web/TargetMarker'

View file

@ -0,0 +1,43 @@
import { State } from './Lists'
enum StorageType {
REDUX = "redux",
MOBX = "mobx",
VUEX = "vuex",
NGRX = "ngrx",
ZUSTAND = "zustand",
NONE = 0,
}
export const STORAGE_TYPES = StorageType
export function selectStorageType(state: State): StorageType {
if (!state.reduxList) return STORAGE_TYPES.NONE
if (state.reduxList.length > 0) {
return STORAGE_TYPES.REDUX
} else if (state.vuexList.length > 0) {
return STORAGE_TYPES.VUEX
} else if (state.mobxList.length > 0) {
return STORAGE_TYPES.MOBX
} else if (state.ngrxList.length > 0) {
return STORAGE_TYPES.NGRX
} else if (state.zustandList.length > 0) {
return STORAGE_TYPES.ZUSTAND
}
return STORAGE_TYPES.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 []
}