diff --git a/client/config/ui.js b/client/config/ui.js index 35d773f..2eab671 100644 --- a/client/config/ui.js +++ b/client/config/ui.js @@ -1,3 +1,5 @@ +import {RocketChat} from 'meteor/rocketchat:lib'; + Meteor.startup(function() { RocketChat.AdminBox.addOption({ href: 'admin-chatpal', @@ -14,3 +16,21 @@ Meteor.startup(function() { template: 'ChatpalSearch' }); }); + +RocketChat.callbacks.add('enter-room', () => { + Meteor.call('chatpal.config.get', (err, config) => { + if (err) { + RocketChat.TabBar.updateButton('message-search', { + i18nTitle: 'Search_Messages', + icon: 'magnifier', + template: 'messageSearch' + }); + } else if (config.chatpalActivated) { + RocketChat.TabBar.updateButton('message-search', { + i18nTitle: 'CHATPAL_SEARCH', + icon: 'chatpal', + template: 'ChatpalSearch' + }); + } + }); +}, RocketChat.callbacks.priority.MEDIUM); diff --git a/client/template/admin.js b/client/template/admin.js index 601b569..207adc8 100644 --- a/client/template/admin.js +++ b/client/template/admin.js @@ -142,20 +142,6 @@ Template.ChatpalAdmin.onCreated(function() { } toastr.info(TAPi18n.__('CHATPAL_MSG_INFO_CONFIG_STORED_SUCCESSFULLY')); - - if (config.chatpalActivated) { - RocketChat.TabBar.updateButton('message-search', { - i18nTitle: 'CHATPAL_SEARCH', - icon: 'chatpal', - template: 'ChatpalSearch' - }); - } else { - RocketChat.TabBar.updateButton('message-search', { - i18nTitle: 'Search_Messages', - icon: 'magnifier', - template: 'messageSearch', - }); - } }); };