import { ActionRemote, ActionStateSetLocal, ActionStateSetRemote } from './actions'; import { GlobalState } from './reducer/types'; export const isMaster = (state: Pick): boolean => state.player.master === state.myClientName; export const isActiveClient = (state: Pick): boolean => isMaster(state) || state.player.activeClients.includes(state.myClientName); export const isFromOurselves = ( state: Pick, action: ActionRemote, ): boolean => state.myClientName === action.fromClient; export const willBeMaster = ( state: Partial & Pick, action: ActionStateSetLocal | ActionStateSetRemote, ): boolean => state.myClientName === action.payload?.master; export const getSongId = (state: Pick): number | null => state.player.songId;