Skip to content

Commit

Permalink
Do not try to establish connection if getmyid failed
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoSpy authored Aug 6, 2021
1 parent a7c5353 commit 04e8299
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions public/assets/js/mattermostchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<p class="bg-danger">'+data.responseJSON.detail+'</p>');
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');
Expand Down Expand Up @@ -1061,4 +1062,4 @@
return outOfView;
}
});
})(jQuery);
})(jQuery);

0 comments on commit 04e8299

Please sign in to comment.