Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

[RN] Fix legacy recent-list storage

Zoltan Bettenbuk6e05cab46e62
diff --git a/react/features/recent-list/constants.js b/react/features/recent-list/constants.js
index fa92058882..85cd187cbb 100644
--- a/react/features/recent-list/constants.js
+++ b/react/features/recent-list/constants.js
@@ -4,11 +4,3 @@
* @type {number}
*/
export const LIST_SIZE = 30;
-
-/**
- * The name of the {@code window.localStorage} item where recent rooms are
- * stored.
- *
- * @type {string}
- */
-export const RECENT_URL_STORAGE = 'recentURLs';
diff --git a/react/features/recent-list/functions.js b/react/features/recent-list/functions.js
index c8e2809db4..96160d6729 100644
--- a/react/features/recent-list/functions.js
+++ b/react/features/recent-list/functions.js
@@ -31,6 +31,37 @@ require('moment/locale/zh-cn');
import { i18next } from '../base/i18n';
import { parseURIString } from '../base/util';
+const logger = require('jitsi-meet-logger').getLogger(__filename);
+
+/**
+ * The name of the {@code window.localStorage} item where recent rooms are
+ * stored.
+ *
+ * @type {string}
+ */
+const RECENT_URL_STORAGE = 'recentURLs';
+
+/**
+ * Retrieves the recent room list that was stored using the legacy way.
+ *
+ * @returns {Array<Object>}
+ */
+export function getLegacyRecentRoomList(): Array<Object> {
+ const legacyListString = window.localStorage.getItem(RECENT_URL_STORAGE);
+
+ try {
+ const legacyList = JSON.parse(legacyListString);
+
+ if (legacyList && legacyList.length) {
+ return legacyList;
+ }
+ } catch (error) {
+ logger.warn('Unable to parse legacy recent list');
+ }
+
+ return [];
+}
+
/**
* Retrieves the recent room list and generates all the data needed to be
* displayed.
diff --git a/react/features/recent-list/reducer.js b/react/features/recent-list/reducer.js
index ca4dcafe9b..2024b97f1a 100644
--- a/react/features/recent-list/reducer.js
+++ b/react/features/recent-list/reducer.js
@@ -7,13 +7,7 @@ import {
UPDATE_CONFERENCE_DURATION
} from './actionTypes';
import { LIST_SIZE } from './constants';
-
-/**
- * The initial state of this feature.
- */
-const DEFAULT_STATE = {
- list: []
-};
+import { getLegacyRecentRoomList } from './functions';
/**
* The Redux subtree of this feature.
@@ -30,7 +24,9 @@ PersistencyRegistry.register(STORE_NAME, {
/**
* Reduces the Redux actions of the feature features/recent-list.
*/
-ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {
+ReducerRegistry.register(STORE_NAME, (state = {
+ list: getLegacyRecentRoomList()
+}, action) => {
switch (action.type) {
case STORE_CURRENT_CONFERENCE:
return _storeCurrentConference(state, action);