Skip to content

Commit

Permalink
Merge pull request #34 from trixtateam/fix/join_channel_events_on_join
Browse files Browse the repository at this point in the history
fix: include events on join of channel
  • Loading branch information
jacqueswho authored Aug 23, 2022
2 parents 058e995 + e659b56 commit 5218f90
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/middlewares/phoenix/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ export function connectToPhoenixChannelForEvents({
dispatch(endPhoenixChannelProgress({ channelTopic, loadingStatusKey: channelTopic }));
});

if (Array.isArray(events)) {
events.forEach(({ eventName, eventActionType }) => {
const bindings = get(channel, 'bindings', []);
if (!bindings.find(({ event }) => event === eventName)) {
channel.on(eventName, (data) => {
dispatch({ type: eventActionType, data, eventName, channelTopic });
});
}
});
}

return {
type: channelActionTypes.CHANNEL_UPDATED,
presence,
Expand Down

0 comments on commit 5218f90

Please sign in to comment.