Skip to content

Commit

Permalink
update webchat channel
Browse files Browse the repository at this point in the history
  • Loading branch information
rockwellll committed Jan 13, 2025
1 parent 67bf283 commit 11eb877
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/hellotext.js

Large diffs are not rendered by default.

21 changes: 19 additions & 2 deletions lib/channels/webchat_channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ var WebchatChannel = /*#__PURE__*/function (_ApplicationChannel) {
identifier: params
});
}
}, {
key: "unsubscribe",
value: function unsubscribe() {
var params = {
channel: "WebchatChannel",
id: this.id,
session: this.session,
conversation: this.conversation
};
this.send({
command: 'unsubscribe',
identifier: params
});
}
}, {
key: "onMessage",
value: function onMessage(callback) {
Expand Down Expand Up @@ -85,8 +99,11 @@ var WebchatChannel = /*#__PURE__*/function (_ApplicationChannel) {
}, {
key: "updateSubscriptionWith",
value: function updateSubscriptionWith(conversation) {
this.conversation = conversation;
this.subscribe();
this.unsubscribe();
setTimeout(() => {
this.conversation = conversation;
this.subscribe();
}, 1000);
}
}]);
return WebchatChannel;
Expand Down
19 changes: 17 additions & 2 deletions src/channels/webchat_channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ class WebchatChannel extends ApplicationChannel {
this.send( { command: 'subscribe', identifier: params })
}

unsubscribe() {
const params = {
channel: "WebchatChannel",
id: this.id,
session: this.session,
conversation: this.conversation,
}

this.send({ command: 'unsubscribe', identifier: params })
}

onMessage(callback) {
super.onMessage((message) => {
if(message.type !== 'message') return
Expand Down Expand Up @@ -54,8 +65,12 @@ class WebchatChannel extends ApplicationChannel {
}

updateSubscriptionWith(conversation) {
this.conversation = conversation
this.subscribe()
this.unsubscribe()

setTimeout(() => {
this.conversation = conversation
this.subscribe()
}, 1000)
}
}

Expand Down

0 comments on commit 11eb877

Please sign in to comment.