瀏覽代碼

[RN] Fix legacy recent-list storage

master
Zoltan Bettenbuk 7 年之前
父節點
當前提交
6e05cab46e

+ 0
- 8
react/features/recent-list/constants.js 查看文件

4
  * @type {number}
4
  * @type {number}
5
  */
5
  */
6
 export const LIST_SIZE = 30;
6
 export const LIST_SIZE = 30;
7
-
8
-/**
9
- * The name of the {@code window.localStorage} item where recent rooms are
10
- * stored.
11
- *
12
- * @type {string}
13
- */
14
-export const RECENT_URL_STORAGE = 'recentURLs';

+ 31
- 0
react/features/recent-list/functions.js 查看文件

31
 import { i18next } from '../base/i18n';
31
 import { i18next } from '../base/i18n';
32
 import { parseURIString } from '../base/util';
32
 import { parseURIString } from '../base/util';
33
 
33
 
34
+const logger = require('jitsi-meet-logger').getLogger(__filename);
35
+
36
+/**
37
+ * The name of the {@code window.localStorage} item where recent rooms are
38
+ * stored.
39
+ *
40
+ * @type {string}
41
+ */
42
+const RECENT_URL_STORAGE = 'recentURLs';
43
+
44
+/**
45
+ * Retrieves the recent room list that was stored using the legacy way.
46
+ *
47
+ * @returns {Array<Object>}
48
+ */
49
+export function getLegacyRecentRoomList(): Array<Object> {
50
+    const legacyListString = window.localStorage.getItem(RECENT_URL_STORAGE);
51
+
52
+    try {
53
+        const legacyList = JSON.parse(legacyListString);
54
+
55
+        if (legacyList && legacyList.length) {
56
+            return legacyList;
57
+        }
58
+    } catch (error) {
59
+        logger.warn('Unable to parse legacy recent list');
60
+    }
61
+
62
+    return [];
63
+}
64
+
34
 /**
65
 /**
35
  * Retrieves the recent room list and generates all the data needed to be
66
  * Retrieves the recent room list and generates all the data needed to be
36
  * displayed.
67
  * displayed.

+ 4
- 8
react/features/recent-list/reducer.js 查看文件

7
     UPDATE_CONFERENCE_DURATION
7
     UPDATE_CONFERENCE_DURATION
8
 } from './actionTypes';
8
 } from './actionTypes';
9
 import { LIST_SIZE } from './constants';
9
 import { LIST_SIZE } from './constants';
10
-
11
-/**
12
- * The initial state of this feature.
13
- */
14
-const DEFAULT_STATE = {
15
-    list: []
16
-};
10
+import { getLegacyRecentRoomList } from './functions';
17
 
11
 
18
 /**
12
 /**
19
  * The Redux subtree of this feature.
13
  * The Redux subtree of this feature.
30
 /**
24
 /**
31
  * Reduces the Redux actions of the feature features/recent-list.
25
  * Reduces the Redux actions of the feature features/recent-list.
32
  */
26
  */
33
-ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {
27
+ReducerRegistry.register(STORE_NAME, (state = {
28
+    list: getLegacyRecentRoomList()
29
+}, action) => {
34
     switch (action.type) {
30
     switch (action.type) {
35
     case STORE_CURRENT_CONFERENCE:
31
     case STORE_CURRENT_CONFERENCE:
36
         return _storeCurrentConference(state, action);
32
         return _storeCurrentConference(state, action);

Loading…
取消
儲存