[RN] Fix legacy recent-list storage
This commit is contained in:
parent
7954d5fd39
commit
6e05cab46e
|
@ -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';
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue