diff --git a/app/livechat/client/views/app/livechatCustomFieldForm.js b/app/livechat/client/views/app/livechatCustomFieldForm.js index c3ac8eb67b1..0a821fa4421 100644 --- a/app/livechat/client/views/app/livechatCustomFieldForm.js +++ b/app/livechat/client/views/app/livechatCustomFieldForm.js @@ -5,8 +5,8 @@ import { Template } from 'meteor/templating'; import toastr from 'toastr'; import { t, handleError } from '../../../../utils'; -import { LivechatCustomField } from '../../collections/LivechatCustomField'; import './livechatCustomFieldForm.html'; +import { APIClient } from '../../../../utils/client'; Template.livechatCustomFieldForm.helpers({ customField() { @@ -60,15 +60,10 @@ Template.livechatCustomFieldForm.events({ }, }); -Template.livechatCustomFieldForm.onCreated(function() { +Template.livechatCustomFieldForm.onCreated(async function() { this.customField = new ReactiveVar({}); - this.autorun(() => { - const sub = this.subscribe('livechat:customFields', FlowRouter.getParam('_id')); - if (sub.ready()) { - const customField = LivechatCustomField.findOne({ _id: FlowRouter.getParam('_id') }); - if (customField) { - this.customField.set(customField); - } - } - }); + const { customField } = await APIClient.v1.get(`livechat/custom-fields/${ FlowRouter.getParam('_id') }`); + if (customField) { + this.customField.set(customField); + } }); diff --git a/app/livechat/client/views/app/livechatCustomFields.html b/app/livechat/client/views/app/livechatCustomFields.html index 6edb287a95f..07fbeaedcfb 100644 --- a/app/livechat/client/views/app/livechatCustomFields.html +++ b/app/livechat/client/views/app/livechatCustomFields.html @@ -1,7 +1,7 @@