Skip to content

Commit

Permalink
Dispatch last execution update action when message on channel is rece…
Browse files Browse the repository at this point in the history
…ived
  • Loading branch information
fabriziosestito committed Dec 1, 2022
1 parent a7e1261 commit 7cb31b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion assets/js/state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
2 changes: 1 addition & 1 deletion assets/js/state/registerSocketEvents.js
Original file line number Diff line number Diff line change
@@ -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))
Expand Down

0 comments on commit 7cb31b4

Please sign in to comment.