diff --git a/webapp/components/post_view/post/post.jsx b/webapp/components/post_view/post/post.jsx
index eda4405bb8..4491d888ca 100644
--- a/webapp/components/post_view/post/post.jsx
+++ b/webapp/components/post_view/post/post.jsx
@@ -199,13 +199,6 @@ export default class Post extends React.PureComponent {
const isSystemMessage = PostUtils.isSystemMessage(post);
const fromWebhook = post.props && post.props.from_webhook === 'true';
- let timestamp = 0;
- if (!this.props.user || this.props.user.last_picture_update == null) {
- timestamp = this.props.currentUser.last_picture_update;
- } else {
- timestamp = this.props.user.last_picture_update;
- }
-
let status = this.props.status;
if (fromWebhook) {
status = null;
@@ -213,7 +206,7 @@ export default class Post extends React.PureComponent {
let profilePic = (
);
} else if (PostUtils.isSystemMessage(post)) {
diff --git a/webapp/components/rhs_comment.jsx b/webapp/components/rhs_comment.jsx
index 568d853046..6592c487d4 100644
--- a/webapp/components/rhs_comment.jsx
+++ b/webapp/components/rhs_comment.jsx
@@ -212,8 +212,6 @@ export default class RhsComment extends React.Component {
const isEphemeral = Utils.isPostEphemeral(post);
const isSystemMessage = PostUtils.isSystemMessage(post);
- var timestamp = this.props.currentUser.last_picture_update;
-
let status = this.props.status;
if (post.props && post.props.from_webhook === 'true') {
status = null;
@@ -277,7 +275,7 @@ export default class RhsComment extends React.Component {
let profilePic = (
diff --git a/webapp/components/rhs_root_post.jsx b/webapp/components/rhs_root_post.jsx
index fa72da1674..1a28dc0087 100644
--- a/webapp/components/rhs_root_post.jsx
+++ b/webapp/components/rhs_root_post.jsx
@@ -196,7 +196,6 @@ export default class RhsRootPost extends React.Component {
const post = this.props.post;
const user = this.props.user;
const mattermostLogo = Constants.MATTERMOST_ICON_SVG;
- var timestamp = user ? user.last_picture_update : 0;
var channel = ChannelStore.get(post.channel_id);
const isEphemeral = Utils.isPostEphemeral(post);
@@ -303,7 +302,7 @@ export default class RhsRootPost extends React.Component {
let profilePic = (
diff --git a/webapp/components/search_results_item.jsx b/webapp/components/search_results_item.jsx
index 3b632ee5e2..56b91fe686 100644
--- a/webapp/components/search_results_item.jsx
+++ b/webapp/components/search_results_item.jsx
@@ -9,7 +9,6 @@ import ProfilePicture from './profile_picture.jsx';
import CommentIcon from 'components/common/comment_icon.jsx';
import TeamStore from 'stores/team_store.jsx';
-import UserStore from 'stores/user_store.jsx';
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
@@ -113,7 +112,6 @@ export default class SearchResultsItem extends React.Component {
render() {
let channelName = null;
const channel = this.props.channel;
- const timestamp = UserStore.getCurrentUser().last_picture_update;
const user = this.props.user || {};
const post = this.props.post;
@@ -154,7 +152,7 @@ export default class SearchResultsItem extends React.Component {
const profilePic = (
);
}
diff --git a/webapp/components/suggestion/search_user_provider.jsx b/webapp/components/suggestion/search_user_provider.jsx
index d05d42a54e..f3191c408a 100644
--- a/webapp/components/suggestion/search_user_provider.jsx
+++ b/webapp/components/suggestion/search_user_provider.jsx
@@ -7,7 +7,6 @@ import Provider from './provider.jsx';
import {autocompleteUsersInTeam} from 'actions/user_actions.jsx';
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
-import {Client4} from 'mattermost-redux/client';
import * as Utils from 'utils/utils.jsx';
import {ActionTypes} from 'utils/constants.jsx';
@@ -41,7 +40,7 @@ class SearchUserSuggestion extends Suggestion {
diff --git a/webapp/components/suggestion/switch_channel_provider.jsx b/webapp/components/suggestion/switch_channel_provider.jsx
index ba060d9248..ac4af9c8b6 100644
--- a/webapp/components/suggestion/switch_channel_provider.jsx
+++ b/webapp/components/suggestion/switch_channel_provider.jsx
@@ -58,7 +58,7 @@ class SwitchChannelSuggestion extends Suggestion {
);
@@ -239,7 +239,8 @@ export default class SwitchChannelProvider extends Provider {
name: user.username,
id: user.id,
update_at: user.update_at,
- type: Constants.DM_CHANNEL
+ type: Constants.DM_CHANNEL,
+ last_picture_update: user.last_picture_update || 0
},
name: user.username
};
diff --git a/webapp/components/user_profile.jsx b/webapp/components/user_profile.jsx
index 1cd2ef6372..d8549cc7bb 100644
--- a/webapp/components/user_profile.jsx
+++ b/webapp/components/user_profile.jsx
@@ -3,7 +3,6 @@
import ProfilePopover from './profile_popover.jsx';
import * as Utils from 'utils/utils.jsx';
-import {Client4} from 'mattermost-redux/client';
import {OverlayTrigger} from 'react-bootstrap';
@@ -59,7 +58,7 @@ export default class UserProfile extends React.Component {
if (this.props.user) {
name = Utils.displayUsername(this.props.user.id);
- profileImg = Client4.getUsersRoute() + '/' + this.props.user.id + '/image?time=' + this.props.user.last_picture_update;
+ profileImg = Utils.imageURLForUser(this.props.user);
}
if (this.props.overwriteName) {
diff --git a/webapp/components/user_settings/user_settings_general/user_settings_general.jsx b/webapp/components/user_settings/user_settings_general/user_settings_general.jsx
index 0f04591802..613744b43b 100644
--- a/webapp/components/user_settings/user_settings_general/user_settings_general.jsx
+++ b/webapp/components/user_settings/user_settings_general/user_settings_general.jsx
@@ -9,7 +9,6 @@ import SettingPicture from 'components/setting_picture.jsx';
import UserStore from 'stores/user_store.jsx';
import ErrorStore from 'stores/error_store.jsx';
-import {Client4} from 'mattermost-redux/client';
import Constants from 'utils/constants.jsx';
import * as Utils from 'utils/utils.jsx';
@@ -1141,7 +1140,7 @@ class UserSettingsGeneralTab extends React.Component {
{
diff --git a/webapp/components/webrtc/components/webrtc_notification.jsx b/webapp/components/webrtc/components/webrtc_notification.jsx
index 2c21924b26..efa6ee6373 100644
--- a/webapp/components/webrtc/components/webrtc_notification.jsx
+++ b/webapp/components/webrtc/components/webrtc_notification.jsx
@@ -1,7 +1,6 @@
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
-import {Client4} from 'mattermost-redux/client';
import WebSocketClient from 'client/web_websocket_client.jsx';
import UserStore from 'stores/user_store.jsx';
@@ -197,7 +196,7 @@ export default class WebrtcNotification extends React.Component {
const user = this.state.userCalling;
if (user) {
const username = Utils.displayUsername(user.id);
- const profileImgSrc = Client4.getUsersRoute() + '/' + user.id + '/image?time=' + (user.last_picture_update || new Date().getTime());
+ const profileImgSrc = Utils.imageURLForUser(user);
const profileImg = (
0;
}
-export function getProfilePicSrcForPost(post, timestamp) {
- let src = Client4.getUsersRoute() + '/' + post.user_id + '/image?time=' + timestamp;
+export function getProfilePicSrcForPost(post, user) {
+ let src = '';
+ if (user && user.id === post.user_id) {
+ src = Utils.imageURLForUser(user);
+ } else {
+ src = Utils.imageURLForUser(post.user_id);
+ }
+
if (post.props && post.props.from_webhook && global.window.mm_config.EnablePostIconOverride === 'true') {
if (post.props.override_icon_url) {
src = post.props.override_icon_url;
diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx
index b14bdaf112..0bd8c7bffa 100644
--- a/webapp/utils/utils.jsx
+++ b/webapp/utils/utils.jsx
@@ -1023,6 +1023,17 @@ export function displayUsernameForUser(user) {
return '';
}
+export function imageURLForUser(userIdOrObject) {
+ if (typeof userIdOrObject == 'string') {
+ const profile = UserStore.getProfile(userIdOrObject);
+ if (profile) {
+ return imageURLForUser(profile);
+ }
+ return Client4.getUsersRoute() + '/' + userIdOrObject + '/image?_=' + Date.now();
+ }
+ return Client4.getUsersRoute() + '/' + userIdOrObject.id + '/image?_=' + (userIdOrObject.last_picture_update || 0);
+}
+
// Converts a file size in bytes into a human-readable string of the form '123MB'.
export function fileSizeToString(bytes) {
// it's unlikely that we'll have files bigger than this