Adds avatarId to Settings.

This commit is contained in:
damencho 2016-08-31 11:24:51 -05:00
parent 5ab6c551df
commit 3852b34397
1 changed files with 16 additions and 0 deletions

View File

@ -3,6 +3,7 @@
import UIUtil from '../UI/util/UIUtil'; import UIUtil from '../UI/util/UIUtil';
let email = ''; let email = '';
let avatarId = '';
let displayName = ''; let displayName = '';
let language = null; let language = null;
let cameraDeviceId = ''; let cameraDeviceId = '';
@ -35,6 +36,13 @@ if (supportsLocalStorage()) {
} }
email = UIUtil.unescapeHtml(window.localStorage.email || ''); email = UIUtil.unescapeHtml(window.localStorage.email || '');
avatarId = UIUtil.unescapeHtml(window.localStorage.avatarId || '');
if (!avatarId) {
// if there is no avatar id, we generate a unique one and use it forever
avatarId = generateUniqueId();
window.localStorage.avatarId = avatarId;
}
localFlipX = JSON.parse(window.localStorage.localFlipX || true); localFlipX = JSON.parse(window.localStorage.localFlipX || true);
displayName = UIUtil.unescapeHtml(window.localStorage.displayname || ''); displayName = UIUtil.unescapeHtml(window.localStorage.displayname || '');
language = window.localStorage.language; language = window.localStorage.language;
@ -105,6 +113,14 @@ export default {
return email; return email;
}, },
/**
* Returns avatar id of the local user.
* @returns {string} avatar id
*/
getAvatarId: function () {
return avatarId;
},
/** /**
* Sets new avatarUrl for local user and saves it to the local storage. * Sets new avatarUrl for local user and saves it to the local storage.
* @param {string} newAvatarUrl new avatarUrl for the local user * @param {string} newAvatarUrl new avatarUrl for the local user