From 9c04dd8fc62ac898d846ec86a9d70caa8d68686e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20J=C3=A4gle?= Date: Fri, 21 Jul 2017 10:37:30 +0200 Subject: [PATCH] Harmonize behavior of live chats and requests with respect to actions handling Fixes #44 Do not open Assistify-tab if running in the mobile app (fixes #41). However, a browser opening the mobile view is likely to open the panel on opening the room still. --- .../assistify-help-request/client/hooks/openAiTab.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/assistify-help-request/client/hooks/openAiTab.js b/packages/assistify-help-request/client/hooks/openAiTab.js index 4400cbeabc33..1dd88a04045a 100644 --- a/packages/assistify-help-request/client/hooks/openAiTab.js +++ b/packages/assistify-help-request/client/hooks/openAiTab.js @@ -3,8 +3,14 @@ * (a request, an expertise or a livechat) */ RocketChat.callbacks.add('enter-room', function(subscription) { - const roomOpened = RocketChat.models.Rooms.findOne({_id: subscription.rid}); - if (roomOpened.t === 'r' || roomOpened.t === 'e' || roomOpened.t === 'l') { - $('.flex-tab-container:not(.opened) .flex-tab-bar :not(.hidden) .icon-lightbulb').click(); //there is no ID of the tabbar's Button which we could use so far + if (Meteor.isCordova) { + return; //looks awkward on mobile if panel is opened by default + } + + if (subscription) { //no subscription: if a user joins a room without being subscribed to it, e. g. in live chat + const roomOpened = RocketChat.models.Rooms.findOne({_id: subscription.rid}); + if (roomOpened.t === 'r' || roomOpened.t === 'e' || roomOpened.t === 'l') { + $('.flex-tab-container:not(.opened) .flex-tab-bar :not(.hidden) .icon-lightbulb').click(); //there is no ID of the tabbar's Button which we could use so far + } } });