[RN] Fix legacy recent-list storage
This commit is contained in:
parent
7954d5fd39
commit
6e05cab46e
|
@ -4,11 +4,3 @@
|
||||||
* @type {number}
|
* @type {number}
|
||||||
*/
|
*/
|
||||||
export const LIST_SIZE = 30;
|
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 { i18next } from '../base/i18n';
|
||||||
import { parseURIString } from '../base/util';
|
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
|
* Retrieves the recent room list and generates all the data needed to be
|
||||||
* displayed.
|
* displayed.
|
||||||
|
|
|
@ -7,13 +7,7 @@ import {
|
||||||
UPDATE_CONFERENCE_DURATION
|
UPDATE_CONFERENCE_DURATION
|
||||||
} from './actionTypes';
|
} from './actionTypes';
|
||||||
import { LIST_SIZE } from './constants';
|
import { LIST_SIZE } from './constants';
|
||||||
|
import { getLegacyRecentRoomList } from './functions';
|
||||||
/**
|
|
||||||
* The initial state of this feature.
|
|
||||||
*/
|
|
||||||
const DEFAULT_STATE = {
|
|
||||||
list: []
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Redux subtree of this feature.
|
* The Redux subtree of this feature.
|
||||||
|
@ -30,7 +24,9 @@ PersistencyRegistry.register(STORE_NAME, {
|
||||||
/**
|
/**
|
||||||
* Reduces the Redux actions of the feature features/recent-list.
|
* 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) {
|
switch (action.type) {
|
||||||
case STORE_CURRENT_CONFERENCE:
|
case STORE_CURRENT_CONFERENCE:
|
||||||
return _storeCurrentConference(state, action);
|
return _storeCurrentConference(state, action);
|
||||||
|
|
Loading…
Reference in New Issue