Skip to content

Commit

Permalink
[FIX] Omnichannel room info panel opening whenever a message is sent (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
renatobecker authored Apr 20, 2020
1 parent cbe746c commit 5a06e4b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 28 deletions.
29 changes: 29 additions & 0 deletions app/livechat/client/hooks/onCreateRoomTabBar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { callbacks } from '../../../callbacks';

callbacks.add('onCreateRoomTabBar', (info) => {
const { tabBar, room } = info;

if (!tabBar) {
return info;
}

if (!room || !room.t || room.t !== 'l') {
return info;
}

const button = tabBar.getButtons().find((button) => button.id === 'visitor-info');
if (!button) {
return info;
}

const { template, i18nTitle: label, icon } = button;
tabBar.setTemplate(template);
tabBar.setData({
label,
icon,
});

tabBar.open();

return info;
});
25 changes: 0 additions & 25 deletions app/livechat/client/hooks/onRenderRoom.js

This file was deleted.

2 changes: 1 addition & 1 deletion app/livechat/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '../lib/messageTypes';
import './roomType';
import './route';
import './ui';
import './hooks/onRenderRoom';
import './hooks/onCreateRoomTabBar';
import './startup/notifyUnreadRooms';
import './stylesheets/livechat.css';
import './views/sideNav/livechat';
Expand Down
6 changes: 4 additions & 2 deletions app/ui/client/views/app/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -1072,6 +1072,10 @@ Template.room.onCreated(function() {

this.tabBar = new RocketChatTabBar();
this.tabBar.showGroup(FlowRouter.current().route.name);
callbacks.run('onCreateRoomTabBar', {
tabBar: this.tabBar,
room: Rooms.findOne(rid, { fields: { t: 1 } }),
});

this.hideLeaderHeader = new ReactiveVar(false);

Expand Down Expand Up @@ -1378,8 +1382,6 @@ Template.room.onRendered(function() {
if (!room) {
return FlowRouter.go('home');
}

callbacks.run('onRenderRoom', template, room);
});

const observer = new ResizeObserver(template.sendToBottomIfNecessary);
Expand Down

0 comments on commit 5a06e4b

Please sign in to comment.