Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions src/components/Functions/Realtime/SubscribeChannel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,6 @@
:model-value="self"
@update:modelValue="setSelf"
/>
<wwEditorInputRow
type="onoff"
label="Listen presence"
tooltip="Define if you want to receive presence events"
bindable
small
:model-value="presence"
@update:modelValue="setPresence"
/>
<wwLoader :loading="isLoading" />
</template>

Expand Down Expand Up @@ -141,9 +132,6 @@ export default {
self() {
return this.args.self ?? false;
},
presence() {
return this.args.presence ?? false;
},
tablesOptions() {
return [
{ label: 'All tables', value: null },
Expand Down Expand Up @@ -173,7 +161,6 @@ export default {
table: null,
filter: null,
self: false,
presence: false,
});
},
setEvent(event) {
Expand All @@ -191,9 +178,6 @@ export default {
setSelf(self) {
this.$emit('update:args', { ...this.args, self });
},
setPresence(presence) {
this.$emit('update:args', { ...this.args, presence });
},
async fetchTables() {
try {
this.isLoading = true;
Expand Down
38 changes: 13 additions & 25 deletions src/wwPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -829,16 +829,7 @@ export default {
return;
}
},
subscribeToChannel({
channel,
type = 'postgres_changes',
event = '*',
schema = '*',
table,
filter,
self = false,
presence = false,
}) {
subscribeToChannel({ channel, type = 'postgres_changes', event = '*', schema = '*', table, filter, self = false }) {
const _channel = this.instance.channel(channel, { config: { broadcast: { self } } });
_channel.on(
type,
Expand All @@ -855,20 +846,18 @@ export default {
});
}
);
if (presence) {
_channel.on(
'presence',
{
event: '*',
},
e => {
wwLib.wwWorkflow.executeTrigger(this.id + '-realtime:presence', {
event: { channel, data: e },
conditions: { channel, event: e.event },
});
}
);
}
_channel.on(
'presence',
{
event: '*',
},
e => {
wwLib.wwWorkflow.executeTrigger(this.id + '-realtime:presence', {
event: { channel, data: e },
conditions: { channel, event: e.event },
});
}
);
_channel.subscribe();
},
unsubscribeFromChannel({ channel }) {
Expand All @@ -877,7 +866,6 @@ export default {
this.instance.removeChannel(_channel);
},
sendMessageToChannel({ channel, type = 'broadcast', event, payload }) {
debugger;
const _channel = this.instance.getChannels().find(c => c.subTopic === channel);
if (!_channel) throw new Error('Channel not found, please subscribe to the channel before sending a message.');
_channel.send({ type, event, payload });
Expand Down