Skip to content

Commit

Permalink
Remove local avatar
Browse files Browse the repository at this point in the history
The deployment will generate the right one based on the provided name
and email.

Fixes: #379
  • Loading branch information
saghul committed Jun 4, 2020
1 parent 09345d6 commit 8de41a4
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 146 deletions.
23 changes: 1 addition & 22 deletions app/features/conference/components/Conference.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ type Props = {
*/
_alwaysOnTopWindowEnabled: boolean;

/**
* Avatar URL.
*/
_avatarURL: string;

/**
* Email of user.
*/
Expand Down Expand Up @@ -169,9 +164,6 @@ class Conference extends Component<Props, State> {
componentDidUpdate(prevProps) {
const { props } = this;

if (props._avatarURL !== prevProps._avatarURL) {
this._setAvatarURL(props._avatarURL);
}
if (props._email !== prevProps._email) {
this._setEmail(props._email);
}
Expand Down Expand Up @@ -370,7 +362,6 @@ class Conference extends Component<Props, State> {
* @returns {void}
*/
_onVideoConferenceJoined(conferenceInfo: Object) {
this._setAvatarURL(this.props._avatarURL);
this._setEmail(this.props._email);
this._setName(this.props._name);

Expand All @@ -382,16 +373,6 @@ class Conference extends Component<Props, State> {
(params: Object) => this._onEmailChange(params, id));
}

/**
* Set Avatar URL from settings to conference.
*
* @param {string} avatarURL - Avatar URL.
* @returns {void}
*/
_setAvatarURL(avatarURL: string) {
this._api.executeCommand('avatarUrl', avatarURL);
}

/**
* Set email from settings to conference.
*
Expand Down Expand Up @@ -422,9 +403,7 @@ class Conference extends Component<Props, State> {
*/
function _mapStateToProps(state: Object) {
return {
_alwaysOnTopWindowEnabled:
getSetting(state, 'alwaysOnTopWindowEnabled', true),
_avatarURL: state.settings.avatarURL,
_alwaysOnTopWindowEnabled: getSetting(state, 'alwaysOnTopWindowEnabled', true),
_email: state.settings.email,
_name: state.settings.name,
_serverURL: state.settings.serverURL,
Expand Down
3 changes: 1 addition & 2 deletions app/features/onboarding/components/EmailSettingSpotlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ class EmailSettingSpotlight extends Component<Props, *> {
] }
dialogPlacement = 'left top'
target = { 'email-setting' } >
The email you enter here will be part of your user profile and
it will be used to display your stored avatar in gravatar.com .
The email you enter here will be part of your user profile.
</Spotlight>
);
}
Expand Down
2 changes: 0 additions & 2 deletions app/features/redux/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import { createLogger } from 'redux-logger';

import { middleware as onboardingMiddleware } from '../onboarding';
import { middleware as routerMiddleware } from '../router';
import { middleware as settingsMiddleware } from '../settings';

export default applyMiddleware(
onboardingMiddleware,
routerMiddleware,
settingsMiddleware,
createLogger()
);
10 changes: 0 additions & 10 deletions app/features/settings/actionTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@ export const SET_ALWAYS_ON_TOP_WINDOW_ENABLED
*/
export const SET_AUDIO_MUTED = Symbol('SET_AUDIO_MUTED');

/**
* The type of (redux) action that sets the Avatar URL.
*
* @type {
* type: SET_AVATAR_URL,
* avatarURL: string
* }
*/
export const SET_AVATAR_URL = Symbol('SET_AVATAR_URL');

/**
* The type of (redux) action that sets the email of the user.
*
Expand Down
17 changes: 0 additions & 17 deletions app/features/settings/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import {
SET_ALWAYS_ON_TOP_WINDOW_ENABLED,
SET_AUDIO_MUTED,
SET_AVATAR_URL,
SET_EMAIL,
SET_NAME,
SET_SERVER_URL,
Expand All @@ -13,22 +12,6 @@ import {

import { normalizeServerURL } from '../utils';

/**
* Set Avatar URL.
*
* @param {string} avatarURL - Avatar URL.
* @returns {{
* type: SET_AVATAR_URL,
* avatarURL: string
* }}
*/
export function setAvatarURL(avatarURL: string) {
return {
type: SET_AVATAR_URL,
avatarURL
};
}

/**
* Set the email of the user.
*
Expand Down
5 changes: 3 additions & 2 deletions app/features/settings/components/ServerTimeoutField.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { Dispatch } from 'redux';
import config from '../../config';

import { setServerTimeout } from '../actions';
import { Form } from '../styled';

type Props = {

Expand Down Expand Up @@ -64,7 +65,7 @@ class ServerTimeoutField extends Component<Props, State> {
*/
render() {
return (
<form onSubmit = { this._onServerTimeoutSubmit }>
<Form onSubmit = { this._onServerTimeoutSubmit }>
<FieldTextStateless
invalidMessage
= { 'Invalid Timeout' }
Expand All @@ -77,7 +78,7 @@ class ServerTimeoutField extends Component<Props, State> {
shouldFitContainer = { true }
type = 'number'
value = { this.state.serverTimeout } />
</form>
</Form>
);
}

Expand Down
5 changes: 3 additions & 2 deletions app/features/settings/components/ServerURLField.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import config from '../../config';
import { getExternalApiURL } from '../../utils';

import { setServerURL } from '../actions';
import { Form } from '../styled';

type Props = {

Expand Down Expand Up @@ -65,7 +66,7 @@ class ServerURLField extends Component<Props, State> {
*/
render() {
return (
<form onSubmit = { this._onServerURLSubmit }>
<Form onSubmit = { this._onServerURLSubmit }>
<FieldTextStateless
invalidMessage
= { 'Invalid Server URL or external API not enabled' }
Expand All @@ -78,7 +79,7 @@ class ServerURLField extends Component<Props, State> {
shouldFitContainer = { true }
type = 'text'
value = { this.state.serverURL } />
</form>
</Form>
);
}

Expand Down
32 changes: 8 additions & 24 deletions app/features/settings/components/SettingsDrawer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @flow

import Avatar from '@atlaskit/avatar';
import FieldText from '@atlaskit/field-text';
import ArrowLeft from '@atlaskit/icon/glyph/arrow-left';
import { AkCustomDrawer } from '@atlaskit/navigation';
Expand All @@ -13,7 +12,7 @@ import type { Dispatch } from 'redux';

import { closeDrawer, DrawerContainer, Logo } from '../../navbar';
import { Onboarding, startOnboarding } from '../../onboarding';
import { AvatarContainer, SettingsContainer, TogglesContainer } from '../styled';
import { Form, SettingsContainer, TogglesContainer } from '../styled';
import { setEmail, setName } from '../actions';

import AlwaysOnTopWindowToggle from './AlwaysOnTopWindowToggle';
Expand All @@ -33,11 +32,6 @@ type Props = {
*/
isOpen: boolean;

/**
* Avatar URL.
*/
_avatarURL: string;

/**
* Email of the user.
*/
Expand Down Expand Up @@ -101,32 +95,27 @@ class SettingsDrawer extends Component<Props, *> {
primaryIcon = { <Logo /> } >
<DrawerContainer>
<SettingsContainer>
<AvatarContainer>
<Avatar
size = 'xlarge'
src = { this.props._avatarURL } />
</AvatarContainer>
<SpotlightTarget
name = 'name-setting'>
<form onSubmit = { this._onNameFormSubmit }>
<Form onSubmit = { this._onNameFormSubmit }>
<FieldText
label = 'Name'
onBlur = { this._onNameBlur }
shouldFitContainer = { true }
type = 'text'
value = { this.props._name } />
</form>
</Form>
</SpotlightTarget>
<SpotlightTarget
name = 'email-setting'>
<form onSubmit = { this._onEmailFormSubmit }>
<Form onSubmit = { this._onEmailFormSubmit }>
<FieldText
label = 'Email'
onBlur = { this._onEmailBlur }
shouldFitContainer = { true }
type = 'text'
value = { this.props._email } />
</form>
</Form>
</SpotlightTarget>
<SpotlightTarget
name = 'server-setting'>
Expand Down Expand Up @@ -167,7 +156,7 @@ class SettingsDrawer extends Component<Props, *> {
_onEmailBlur: (*) => void;

/**
* Updates Avatar URL in (redux) state when email is updated.
* Updates email in (redux) state when email is updated.
*
* @param {SyntheticInputEvent<HTMLInputElement>} event - Event by which
* this function is called.
Expand Down Expand Up @@ -196,7 +185,7 @@ class SettingsDrawer extends Component<Props, *> {
_onNameBlur: (*) => void;

/**
* Updates Avatar URL in (redux) state when name is updated.
* Updates name in (redux) state when name is updated.
*
* @param {SyntheticInputEvent<HTMLInputElement>} event - Event by which
* this function is called.
Expand Down Expand Up @@ -227,15 +216,10 @@ class SettingsDrawer extends Component<Props, *> {
* Maps (parts of) the redux state to the React props.
*
* @param {Object} state - The redux state.
* @returns {{
* _avatarURL: string,
* _email: string,
* _name: string
* }}
* @returns {Props}
*/
function _mapStateToProps(state: Object) {
return {
_avatarURL: state.settings.avatarURL,
_email: state.settings.email,
_name: state.settings.name
};
Expand Down
21 changes: 0 additions & 21 deletions app/features/settings/functions.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
// @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.
*
Expand Down
1 change: 0 additions & 1 deletion app/features/settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ export * from './components';
export * from './functions';
export * from './styled';

export { default as middleware } from './middleware';
export { default as reducer } from './reducer';
19 changes: 0 additions & 19 deletions app/features/settings/middleware.js

This file was deleted.

14 changes: 2 additions & 12 deletions app/features/settings/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,27 @@
import {
SET_ALWAYS_ON_TOP_WINDOW_ENABLED,
SET_AUDIO_MUTED,
SET_AVATAR_URL,
SET_EMAIL,
SET_NAME,
SET_SERVER_URL,
SET_SERVER_TIMEOUT,
SET_VIDEO_MUTED
} from './actionTypes';
import { getAvatarURL } from './functions';

type State = {
avatarURL: string,
alwaysOnTopWindowEnabled: boolean,
email: string,
name: string,
serverURL: ?string,
serverTimeout: ?number,
startWithAudioMuted: boolean,
startWithVideoMuted: boolean,
alwaysOnTopWindowEnabled: boolean,
startWithVideoMuted: boolean
};

const username = window.jitsiNodeAPI.osUserInfo().username;

const DEFAULT_STATE = {
alwaysOnTopWindowEnabled: true,
avatarURL: getAvatarURL({ settings: { name: username } }),
email: '',
name: username,
serverURL: undefined,
Expand Down Expand Up @@ -57,12 +53,6 @@ export default (state: State = DEFAULT_STATE, action: Object) => {
startWithAudioMuted: action.startWithAudioMuted
};

case SET_AVATAR_URL:
return {
...state,
avatarURL: action.avatarURL
};

case SET_EMAIL:
return {
...state,
Expand Down
9 changes: 0 additions & 9 deletions app/features/settings/styled/AvatarContainer.js

This file was deleted.

7 changes: 7 additions & 0 deletions app/features/settings/styled/Form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// @flow

import styled from 'styled-components';

export default styled.form`
margin: 0;
`;
Loading

0 comments on commit 8de41a4

Please sign in to comment.