浏览代码

Flatten the store of the recent-list feature

master
zbettenbuk 7 年前
父节点
当前提交
0e07020d09
共有 2 个文件被更改,包括 9 次插入13 次删除
  1. 1
    1
      react/features/recent-list/components/AbstractRecentList.js
  2. 8
    12
      react/features/recent-list/reducer.js

+ 1
- 1
react/features/recent-list/components/AbstractRecentList.js 查看文件

64
 export function _mapStateToProps(state: Object) {
64
 export function _mapStateToProps(state: Object) {
65
     return {
65
     return {
66
         _homeServer: state['features/app'].app._getDefaultURL(),
66
         _homeServer: state['features/app'].app._getDefaultURL(),
67
-        _recentList: state['features/recent-list'].list
67
+        _recentList: state['features/recent-list']
68
     };
68
     };
69
 }
69
 }

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

33
 /**
33
 /**
34
  * Sets up the persistence of the feature recent-list.
34
  * Sets up the persistence of the feature recent-list.
35
  */
35
  */
36
-PersistenceRegistry.register(STORE_NAME, {
37
-    list: true
38
-});
36
+PersistenceRegistry.register(STORE_NAME);
39
 
37
 
40
 /**
38
 /**
41
  * Reduces the redux actions of the feature recent-list.
39
  * Reduces the redux actions of the feature recent-list.
42
  */
40
  */
43
 ReducerRegistry.register(
41
 ReducerRegistry.register(
44
     STORE_NAME,
42
     STORE_NAME,
45
-    (state = { list: _getLegacyRecentRoomList() }, action) => {
43
+    (state = _getLegacyRecentRoomList(), action) => {
46
         switch (action.type) {
44
         switch (action.type) {
47
         case STORE_CURRENT_CONFERENCE:
45
         case STORE_CURRENT_CONFERENCE:
48
             return _storeCurrentConference(state, action);
46
             return _storeCurrentConference(state, action);
88
 
86
 
89
     // If the current conference is already in the list, we remove it to re-add
87
     // If the current conference is already in the list, we remove it to re-add
90
     // it to the top.
88
     // it to the top.
91
-    const list = state.list.filter(e => e.conference !== conference);
89
+    const list = (Array.isArray(state) ? state : [])
90
+        .filter(e => e.conference !== conference);
92
 
91
 
93
     // The list is a reverse-sorted (i.e. the newer elements are at the end).
92
     // The list is a reverse-sorted (i.e. the newer elements are at the end).
94
     list.push({
93
     list.push({
100
     // Ensure the list doesn't exceed a/the maximum size.
99
     // Ensure the list doesn't exceed a/the maximum size.
101
     list.splice(0, list.length - MAX_LIST_SIZE);
100
     list.splice(0, list.length - MAX_LIST_SIZE);
102
 
101
 
103
-    return {
104
-        list
105
-    };
102
+    return list;
106
 }
103
 }
107
 
104
 
108
 /**
105
 /**
116
     const { locationURL } = action;
113
     const { locationURL } = action;
117
 
114
 
118
     if (locationURL && locationURL.href) {
115
     if (locationURL && locationURL.href) {
119
-        const list = state.list;
116
+        // shallow copy to avoid in-place modification.
117
+        const list = (Array.isArray(state) ? state : []).slice();
120
 
118
 
121
         if (list.length > 0) {
119
         if (list.length > 0) {
122
             const mostRecentURL = list[list.length - 1];
120
             const mostRecentURL = list[list.length - 1];
127
                 mostRecentURL.conferenceDuration
125
                 mostRecentURL.conferenceDuration
128
                     = Date.now() - mostRecentURL.date;
126
                     = Date.now() - mostRecentURL.date;
129
 
127
 
130
-                return {
131
-                    list
132
-                };
128
+                return list;
133
             }
129
             }
134
         }
130
         }
135
     }
131
     }

正在加载...
取消
保存