Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Use Client APIs to resolve URLs (#5148)
Browse files Browse the repository at this point in the history
  • Loading branch information
akihikodaki authored and hmhealey committed Jan 31, 2017
1 parent 67739cb commit 7e9cf13
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions webapp/client/test_web_client.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import Client from './client.jsx';

var WebClient = new Client();
export default WebClient;
2 changes: 1 addition & 1 deletion webapp/client/web_client.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class WebClientClass extends Client {
return;
}

if (err.status === HTTP_UNAUTHORIZED && res.req.url !== '/api/v3/users/login') {
if (err.status === HTTP_UNAUTHORIZED && res.req.url !== this.getUsersRoute() + '/login') {
GlobalActions.emitUserLoggedOutEvent('/login');
}

Expand Down
4 changes: 2 additions & 2 deletions webapp/stores/emoji_store.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

import Client from '../client/web_client.jsx';
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
import Constants from 'utils/constants.jsx';
import EventEmitter from 'events';
Expand Down Expand Up @@ -148,8 +149,7 @@ class EmojiStore extends EventEmitter {

getEmojiImageUrl(emoji) {
if (emoji.id) {
// must match Client.getCustomEmojiImageUrl
return `/api/v3/emoji/${emoji.id}`;
return Client.getCustomEmojiImageUrl(emoji.id);
}

const filename = emoji.filename || emoji.aliases[0];
Expand Down
1 change: 1 addition & 0 deletions webapp/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ if (TEST) {
config.entry = ['babel-polyfill', './root.jsx'];
config.target = 'node';
config.externals = [nodeExternals()];
config.resolve.alias['./client/web_client.jsx'] = path.resolve(__dirname, 'client/test_web_client.jsx');
} else {
// For some reason these break mocha. So they go here.
config.plugins.push(
Expand Down

0 comments on commit 7e9cf13

Please sign in to comment.