Skip to content

Commit

Permalink
fix: Canned responses stream not working (#30959)
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman committed Nov 14, 2023
1 parent 8d2d396 commit aaf11e9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
5 changes: 5 additions & 0 deletions .changeset/selfish-panthers-stare.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed Canned responses stream not working, causing users to refresh to see newly created responses.
33 changes: 18 additions & 15 deletions apps/meteor/ee/app/canned-responses/client/startup/responses.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,23 @@ Meteor.startup(() => {
if (!hasPermission('view-canned-responses')) {
return;
}
try {
// TODO: check options
sdk.stream('canned-responses', 'canned-responses', (response, options) => {
const { agentsId } = options || {};
if (Array.isArray(agentsId) && !agentsId.includes(Meteor.userId())) {
return;
}
events[response.type](response);
});
const { responses } = await sdk.rest.get('/v1/canned-responses.get');
responses.forEach((response) => CannedResponse.insert(response));
c.stop();
} catch (error) {
console.log(error);
}
Tracker.afterFlush(() => {
try {
// TODO: check options
sdk.stream('canned-responses', ['canned-responses'], (response, options) => {
const { agentsId } = options || {};
if (Array.isArray(agentsId) && !agentsId.includes(Meteor.userId())) {
return;
}
events[response.type](response);
});
} catch (error) {
console.log(error);
}
});

const { responses } = await sdk.rest.get('/v1/canned-responses.get');
responses.forEach((response) => CannedResponse.insert(response));
c.stop();
});
});

0 comments on commit aaf11e9

Please sign in to comment.