forked from RocketChat/Rocket.Chat
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMPROVEMENT] patch to improve emoji render (RocketChat#14722)
* path to improve emoji render * Apply suggestions from code review Co-Authored-By: Tasso Evangelista <tasso.evangelista@rocket.chat>
- Loading branch information
Showing
3 changed files
with
54 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,40 @@ | ||
import { Session } from 'meteor/session'; | ||
import { Meteor } from 'meteor/meteor'; | ||
import { Tracker } from 'meteor/tracker'; | ||
|
||
import { getAvatarURL } from './getAvatarURL'; | ||
import { settings } from '../../settings'; | ||
|
||
export const getUserAvatarURL = function(username) { | ||
const externalSource = (settings.get('Accounts_AvatarExternalProviderUrl') || '').trim().replace(/\/$/, ''); | ||
if (externalSource !== '') { | ||
return externalSource.replace('{username}', username); | ||
} | ||
if (username == null) { | ||
return; | ||
} | ||
const key = `avatar_random_${ username }`; | ||
const cache = Tracker.nonreactive(() => Session && Session.get(key)); // there is no Session on server | ||
let externalSource = ''; | ||
|
||
return getAvatarURL({ username, cache }); | ||
}; | ||
if (Meteor.isServer) { | ||
settings.get('Accounts_AvatarExternalProviderUrl', (key, value = '') => { | ||
externalSource = value.trim().replace(/\/$/, ''); | ||
}); | ||
} else { | ||
Tracker.autorun(function() { | ||
externalSource = (settings.get('Accounts_AvatarExternalProviderUrl') || '').trim().replace(/\/$/, ''); | ||
}); | ||
} | ||
|
||
export const getUserAvatarURL = Meteor.isServer | ||
? function(username) { | ||
if (username == null) { | ||
return; | ||
} | ||
if (externalSource !== '') { | ||
return externalSource.replace('{username}', username); | ||
} | ||
return getAvatarURL({ username }); | ||
} | ||
: function(username) { | ||
if (username == null) { | ||
return; | ||
} | ||
if (externalSource !== '') { | ||
return externalSource.replace('{username}', username); | ||
} | ||
const key = `avatar_random_${ username }`; | ||
const cache = Tracker.nonreactive(() => Session.get(key)); | ||
return getAvatarURL({ username, cache }); | ||
}; |