fix(player):actually wrap store instead of state & MessageManager init fix

This commit is contained in:
Alex Kaminskii 2022-11-22 17:27:54 +01:00
parent c494f0c0bb
commit b995fa8441
2 changed files with 12 additions and 14 deletions

View file

@ -126,7 +126,7 @@ export default class MessageManager extends Screen {
this.sessionStart = this.session.startedAt
this.lists = new Lists(initialLists)
initialLists && initialLists.event.forEach((e: Record<string, string>) => { // TODO: to one of "Moveable" module
initialLists?.event?.forEach((e: Record<string, string>) => { // TODO: to one of "Moveable" module
if (e.type === EVENT_TYPES.LOCATION) {
this.locationEventManager.append(e);
}

View file

@ -4,31 +4,29 @@ import type { Store } from './player/types'
import WebPlayer, { State as WebState} from './_web/WebPlayer'
type WebPlayerStore = Store<WebState>
export type IWebState = WebState
export type IWebPlayer = WebPlayer
export type IWebPlayerStore = WebPlayerStore
export function createWebPlayer(session: Record<string, any>, wrapState?: (s:IWebState) => IWebState): [IWebPlayer, IWebPlayerStore] {
let state: WebState = {
export function createWebPlayer(session: Record<string, any>, wrapStore?: (s:IWebPlayerStore) => IWebPlayerStore): [IWebPlayer, IWebPlayerStore] {
let store: WebPlayerStore = new SimpleStore<WebState>({
...WebPlayer.INITIAL_STATE,
})
if (wrapStore) {
store = wrapStore(store)
}
if (wrapState) {
state = wrapState(state)
}
const store: WebPlayerStore = new SimpleStore<WebState>(state)
const player = new WebPlayer(store, session, null, false)
return [player, store]
}
export function createLiveWebPlayer(session: Record<string, any>, config: RTCIceServer[], wrapState?: (s:IWebState) => IWebState): [IWebPlayer, IWebPlayerStore] {
let state: WebState = {
export function createLiveWebPlayer(session: Record<string, any>, config: RTCIceServer[], wrapStore?: (s:IWebPlayerStore) => IWebPlayerStore): [IWebPlayer, IWebPlayerStore] {
let store: WebPlayerStore = new SimpleStore<WebState>({
...WebPlayer.INITIAL_STATE,
})
if (wrapStore) {
store = wrapStore(store)
}
if (wrapState) {
state = wrapState(state)
}
const store: WebPlayerStore = new SimpleStore<WebState>(state)
const player = new WebPlayer(store, session, config, true)
return [player, store]