import { IEvents , IPublicWebsocketMessages } from 'superdesk-api' ; import { LIST_ACTION } from '../interfaces' ; import { getStoreSync } from '../store' ; import { setCurrentDeskId } from '../store/workspace/actions' ; import { updateAssetSearchParamsAndListItems } from '../store/assets/actions' ; import { loadSingleDeskSamsSettings } from '../store/workspace/actions' ; import { getSelectedSetId } from '../store/assets/selectors' ; import { getAvailableSetsForDesk } from '../store/sets/selectors' ; export function onActiveDeskChanged ( event ) { const store = getStoreSync ( ) ; store . dispatch < any > ( setCurrentDeskId ( event . desk ) ) ; const state = store . getState ( ) ; const currentSetId = getSelectedSetId ( state ) ; const availableSets = getAvailableSetsForDesk ( state ) ; if ( currentSetId == null || ! availableSets . includes ( currentSetId ) ) { store . dispatch < any > ( updateAssetSearchParamsAndListItems ( { setId : undefined } , LIST_ACTION . REPLACE ) ) ; } } export function onDeskUpdated ( event ) { const store = getStoreSync ( ) ; if ( Object . keys ( event . detail . extra . fields ) . includes ( 'sams_settings' ) ) { store . dispatch < any > ( loadSingleDeskSamsSettings ( event . detail . extra . _id ) ) ; } }