From 04e8299a0be29ff9c3a77da911bcced826ab5c45 Mon Sep 17 00:00:00 2001 From: BrunoSpy Date: Fri, 6 Aug 2021 11:29:28 +0200 Subject: [PATCH] Do not try to establish connection if getmyid failed --- public/assets/js/mattermostchat.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/public/assets/js/mattermostchat.js b/public/assets/js/mattermostchat.js index d59963d..d1b0889 100644 --- a/public/assets/js/mattermostchat.js +++ b/public/assets/js/mattermostchat.js @@ -345,22 +345,23 @@ $.getJSON(self.options.baseUrl + '/mattermost/mattermostchat/getMyChannels?teamid=' + self.options.teamName, function (data) { self._addGroups(data); }); + if(self.options.token !== "") { + self._websocketConnect(); + } else { + $.when($.getJSON(self.options.baseUrl + '/mattermost/mattermostchat/getMyToken', function (data) { + self.options.token = data.token; + Cookies.set('mattermosttoken', data.token); + })).then(function () { + self._websocketConnect(); + }); + } }).fail(function(data, textStatus, jqHXR){ self.element.find('#conversation') .removeClass('load') .append('

'+data.responseJSON.detail+'

'); self.element.find('.chat-reduce button').addClass('btn-danger').removeClass('btn-info'); }); - if(self.options.token !== "") { - self._websocketConnect(); - } else { - $.when($.getJSON(self.options.baseUrl + '/mattermost/mattermostchat/getMyToken', function (data) { - self.options.token = data.token; - Cookies.set('mattermosttoken', data.token); - })).then(function () { - self._websocketConnect(); - }); - } + }, minimize : function() { this.element.find('#reduce-chat').trigger('click'); @@ -1061,4 +1062,4 @@ return outOfView; } }); -})(jQuery); \ No newline at end of file +})(jQuery);