瀏覽代碼

Adds avatarId to Settings.

master
damencho 9 年之前
父節點
當前提交
3852b34397
共有 1 個文件被更改,包括 16 次插入0 次删除
  1. 16
    0
      modules/settings/Settings.js

+ 16
- 0
modules/settings/Settings.js 查看文件

@@ -3,6 +3,7 @@
3 3
 import UIUtil from '../UI/util/UIUtil';
4 4
 
5 5
 let email = '';
6
+let avatarId = '';
6 7
 let displayName = '';
7 8
 let language = null;
8 9
 let cameraDeviceId = '';
@@ -35,6 +36,13 @@ if (supportsLocalStorage()) {
35 36
     }
36 37
 
37 38
     email = UIUtil.unescapeHtml(window.localStorage.email || '');
39
+    avatarId = UIUtil.unescapeHtml(window.localStorage.avatarId || '');
40
+    if (!avatarId) {
41
+        // if there is no avatar id, we generate a unique one and use it forever
42
+        avatarId = generateUniqueId();
43
+        window.localStorage.avatarId = avatarId;
44
+    }
45
+
38 46
     localFlipX = JSON.parse(window.localStorage.localFlipX || true);
39 47
     displayName = UIUtil.unescapeHtml(window.localStorage.displayname || '');
40 48
     language = window.localStorage.language;
@@ -105,6 +113,14 @@ export default {
105 113
         return email;
106 114
     },
107 115
 
116
+    /**
117
+     * Returns avatar id of the local user.
118
+     * @returns {string} avatar id
119
+     */
120
+    getAvatarId: function () {
121
+        return avatarId;
122
+    },
123
+
108 124
     /**
109 125
      * Sets new avatarUrl for local user and saves it to the local storage.
110 126
      * @param {string} newAvatarUrl new avatarUrl for the local user

Loading…
取消
儲存