Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

converted getAvatarUrlFromUsername #6496

Merged
merged 3 commits into from
Mar 29, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions packages/rocketchat-ui/getAvatarUrlFromUsername.coffee

This file was deleted.

17 changes: 17 additions & 0 deletions packages/rocketchat-ui/getAvatarUrlFromUsername.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// TODO: remove global
this.getAvatarUrlFromUsername = function(username) {
const key = `avatar_random_${ username }`;
const random = typeof Session !== 'undefined' ? Session.keys[key] : 0;
if (username == null) {
return;
}
const cdnPrefix = (RocketChat.settings.get('CDN_PREFIX') || '').trim().replace(/\/$/, '');
const pathPrefix = (__meteor_runtime_config__.ROOT_URL_PATH_PREFIX || '').trim().replace(/\/$/, '');
let path = pathPrefix;
if (cdnPrefix) {
path = cdnPrefix + pathPrefix;
} else if (Meteor.isCordova) {
path = Meteor.absoluteUrl().replace(/\/$/, '');
}
return `${ path }/avatar/${ (encodeURIComponent(username)) }?_dc=${ random }`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these extra parenthesis?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inherit from old code, removed.

};
2 changes: 1 addition & 1 deletion packages/rocketchat-ui/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Package.onUse(function(api) {

api.use('kadira:flow-router', 'client');

api.addFiles('getAvatarUrlFromUsername.coffee');
api.addFiles('getAvatarUrlFromUsername.js');

// LIB FILES
api.addFiles('client/lib/accountBox.coffee', 'client');
Expand Down