mirror of
https://github.com/netzbegruenung/jitsi-meet-electron.git
synced 2024-05-04 17:53:41 +02:00
Refactor avatar
Don't use abotars, as they are no longer used in Jitsi Meet.
This commit is contained in:
parent
9b84fe5999
commit
a1a52c4b42
|
@ -1,5 +1,26 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
|
import md5 from 'js-md5';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates an avatar URL for a user, given the name and email settings.
|
||||||
|
*
|
||||||
|
* @param {Object} state - The redux state.
|
||||||
|
* @returns {string} - The generated avatar URL.
|
||||||
|
*/
|
||||||
|
export function getAvatarURL(state: Object) {
|
||||||
|
const { email, name } = state.settings;
|
||||||
|
const encodedName = encodeURIComponent(name || '');
|
||||||
|
|
||||||
|
if (email) {
|
||||||
|
const md5email = md5.hex(email.trim().toLowerCase());
|
||||||
|
|
||||||
|
return `https://www.gravatar.com/avatar/${md5email}?d=https%3A%2F%2Fui-avatars.com%2Fapi%2F/${encodedName}/128`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return `https://ui-avatars.com/api/?name=${encodedName}&size=128`;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get's the value for the given setting, providing a default value.
|
* Get's the value for the given setting, providing a default value.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import { getAvatarURL } from 'js-utils';
|
|
||||||
import { SET_EMAIL, SET_NAME } from './actionTypes';
|
import { SET_EMAIL, SET_NAME } from './actionTypes';
|
||||||
import { setAvatarURL } from './actions';
|
import { setAvatarURL } from './actions';
|
||||||
|
import { getAvatarURL } from './functions';
|
||||||
|
|
||||||
export default (store: Object) => (next: Function) => (action: Object) => {
|
export default (store: Object) => (next: Function) => (action: Object) => {
|
||||||
const result = next(action);
|
const result = next(action);
|
||||||
|
@ -10,14 +10,9 @@ export default (store: Object) => (next: Function) => (action: Object) => {
|
||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case SET_EMAIL:
|
case SET_EMAIL:
|
||||||
case SET_NAME: {
|
case SET_NAME:
|
||||||
const avatarURL = getAvatarURL({
|
store.dispatch(setAvatarURL(getAvatarURL(state)));
|
||||||
email: state.settings.email,
|
|
||||||
id: state.settings.name
|
|
||||||
});
|
|
||||||
|
|
||||||
store.dispatch(setAvatarURL(avatarURL));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import { getAvatarURL } from 'js-utils';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
SET_ALWAYS_ON_TOP_WINDOW_ENABLED,
|
SET_ALWAYS_ON_TOP_WINDOW_ENABLED,
|
||||||
SET_AUDIO_MUTED,
|
SET_AUDIO_MUTED,
|
||||||
|
@ -12,6 +10,7 @@ import {
|
||||||
SET_SERVER_TIMEOUT,
|
SET_SERVER_TIMEOUT,
|
||||||
SET_VIDEO_MUTED
|
SET_VIDEO_MUTED
|
||||||
} from './actionTypes';
|
} from './actionTypes';
|
||||||
|
import { getAvatarURL } from './functions';
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
avatarURL: string,
|
avatarURL: string,
|
||||||
|
@ -28,7 +27,7 @@ const username = window.jitsiNodeAPI.osUserInfo().username;
|
||||||
|
|
||||||
const DEFAULT_STATE = {
|
const DEFAULT_STATE = {
|
||||||
alwaysOnTopWindowEnabled: true,
|
alwaysOnTopWindowEnabled: true,
|
||||||
avatarURL: getAvatarURL({ id: username }),
|
avatarURL: getAvatarURL({ settings: { name: username } }),
|
||||||
email: '',
|
email: '',
|
||||||
name: username,
|
name: username,
|
||||||
serverURL: undefined,
|
serverURL: undefined,
|
||||||
|
|
|
@ -143,6 +143,7 @@
|
||||||
"file-loader": "6.0.0",
|
"file-loader": "6.0.0",
|
||||||
"flow-bin": "0.109.0",
|
"flow-bin": "0.109.0",
|
||||||
"html-webpack-plugin": "4.0.4",
|
"html-webpack-plugin": "4.0.4",
|
||||||
|
"js-md5": "0.7.3",
|
||||||
"patch-package": "6.2.2",
|
"patch-package": "6.2.2",
|
||||||
"precommit-hook": "3.0.0",
|
"precommit-hook": "3.0.0",
|
||||||
"style-loader": "1.1.3",
|
"style-loader": "1.1.3",
|
||||||
|
|
Loading…
Reference in a new issue