diff --git a/assets/js/state/index.js b/assets/js/state/index.js index a26f220777..efe8169faf 100644 --- a/assets/js/state/index.js +++ b/assets/js/state/index.js @@ -14,7 +14,9 @@ import catalogNewReducer from './catalogNew'; import lastExecutionsReducer from './lastExecutions'; import liveFeedReducer from './liveFeed'; import settingsReducer from './settings'; -import registerEvents from './registerSocketEvents'; +import registerEvents, {joinChannel} from './registerSocketEvents'; + +import { updateLastExecution } from '@state/actions/lastExecutions'; import rootSaga from './sagas'; @@ -72,6 +74,16 @@ const processChannelEvents = (store) => { 'database_instance_health_changed', 'database_instance_system_replication_changed', ]); + + // FIXME: This is to overcome the fact that we are generating names with registerEvents + // in the future we want to remove this and use the constants directly, + // since events and actions may have different names and parameters. + const channel = socket.channel('monitoring:executions', {}); + channel.on('execution_completed', ({ group_id: groupID }) => { + store.dispatch(updateLastExecution(groupID)); + }); + + joinChannel(channel); }; processChannelEvents(store); diff --git a/assets/js/state/registerSocketEvents.js b/assets/js/state/registerSocketEvents.js index ae75fec3c8..533b46008f 100644 --- a/assets/js/state/registerSocketEvents.js +++ b/assets/js/state/registerSocketEvents.js @@ -1,6 +1,6 @@ import { logMessage, logError } from '@lib/log'; -const joinChannel = (channel) => { +export const joinChannel = (channel) => { channel .join() .receive('ok', ({ messages }) => logMessage('catching up', messages))