소스 검색

[RN] Fix legacy recent-list storage

master
Zoltan Bettenbuk 7 년 전
부모
커밋
6e05cab46e
3개의 변경된 파일35개의 추가작업 그리고 16개의 파일을 삭제
  1. 0
    8
      react/features/recent-list/constants.js
  2. 31
    0
      react/features/recent-list/functions.js
  3. 4
    8
      react/features/recent-list/reducer.js

+ 0
- 8
react/features/recent-list/constants.js 파일 보기

@@ -4,11 +4,3 @@
4 4
  * @type {number}
5 5
  */
6 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,6 +31,37 @@ require('moment/locale/zh-cn');
31 31
 import { i18next } from '../base/i18n';
32 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 66
  * Retrieves the recent room list and generates all the data needed to be
36 67
  * displayed.

+ 4
- 8
react/features/recent-list/reducer.js 파일 보기

@@ -7,13 +7,7 @@ import {
7 7
     UPDATE_CONFERENCE_DURATION
8 8
 } from './actionTypes';
9 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 13
  * The Redux subtree of this feature.
@@ -30,7 +24,9 @@ PersistencyRegistry.register(STORE_NAME, {
30 24
 /**
31 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 30
     switch (action.type) {
35 31
     case STORE_CURRENT_CONFERENCE:
36 32
         return _storeCurrentConference(state, action);

Loading…
취소
저장