chore(recent-list) remove legacy compatibility code
This commit is contained in:
parent
3e6c988c30
commit
3c370eb6ca
|
@ -1,9 +1,3 @@
|
|||
// @flow
|
||||
|
||||
import Bourne from '@hapi/bourne';
|
||||
import { jitsiLocalStorage } from '@jitsi/js-utils';
|
||||
|
||||
import { APP_WILL_MOUNT } from '../base/app';
|
||||
import { getURLWithoutParamsNormalized } from '../base/connection';
|
||||
import { PersistenceRegistry, ReducerRegistry } from '../base/redux';
|
||||
|
||||
|
@ -13,7 +7,6 @@ import {
|
|||
DELETE_RECENT_LIST_ENTRY
|
||||
} from './actionTypes';
|
||||
import { isRecentListEnabled } from './functions';
|
||||
import logger from './logger';
|
||||
|
||||
/**
|
||||
* The default/initial redux state of the feature {@code recent-list}.
|
||||
|
@ -22,14 +15,6 @@ import logger from './logger';
|
|||
*/
|
||||
const DEFAULT_STATE = [];
|
||||
|
||||
/**
|
||||
* The name of the {@code window.localStorage} item where recent rooms are
|
||||
* stored.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
const LEGACY_STORAGE_KEY = 'recentURLs';
|
||||
|
||||
/**
|
||||
* The max size of the list.
|
||||
*
|
||||
|
@ -50,27 +35,22 @@ PersistenceRegistry.register(STORE_NAME);
|
|||
/**
|
||||
* Reduces redux actions for the purposes of the feature {@code recent-list}.
|
||||
*/
|
||||
ReducerRegistry.register(
|
||||
STORE_NAME,
|
||||
(state = _getLegacyRecentRoomList(), action) => {
|
||||
if (isRecentListEnabled()) {
|
||||
switch (action.type) {
|
||||
case APP_WILL_MOUNT:
|
||||
return _appWillMount(state);
|
||||
case DELETE_RECENT_LIST_ENTRY:
|
||||
return _deleteRecentListEntry(state, action.entryId);
|
||||
case _STORE_CURRENT_CONFERENCE:
|
||||
return _storeCurrentConference(state, action);
|
||||
|
||||
case _UPDATE_CONFERENCE_DURATION:
|
||||
return _updateConferenceDuration(state, action);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
ReducerRegistry.register(STORE_NAME, (state = DEFAULT_STATE, action) => {
|
||||
if (isRecentListEnabled()) {
|
||||
switch (action.type) {
|
||||
case DELETE_RECENT_LIST_ENTRY:
|
||||
return _deleteRecentListEntry(state, action.entryId);
|
||||
case _STORE_CURRENT_CONFERENCE:
|
||||
return _storeCurrentConference(state, action);
|
||||
case _UPDATE_CONFERENCE_DURATION:
|
||||
return _updateConferenceDuration(state, action);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
return state;
|
||||
});
|
||||
return state;
|
||||
});
|
||||
|
||||
/**
|
||||
* Deletes a recent list entry based on the url and date of the item.
|
||||
|
@ -85,57 +65,6 @@ function _deleteRecentListEntry(
|
|||
entry.conference !== entryId.url || entry.date !== entryId.date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduces the redux action {@link APP_WILL_MOUNT}.
|
||||
*
|
||||
* @param {Object} state - The redux state of the feature {@code recent-list}.
|
||||
* @param {Action} action - The redux action {@code APP_WILL_MOUNT}.
|
||||
* @returns {Array<Object>} The next redux state of the feature
|
||||
* {@code recent-list}.
|
||||
*/
|
||||
function _appWillMount(state) {
|
||||
// XXX APP_WILL_MOUNT is the earliest redux action of ours dispatched in the
|
||||
// store. For the purposes of legacy support, make sure that the
|
||||
// deserialized recent-list's state is in the format deemed current by the
|
||||
// current app revision.
|
||||
if (state && typeof state === 'object') {
|
||||
if (Array.isArray(state)) {
|
||||
return state;
|
||||
}
|
||||
|
||||
// In an enterprise/internal build of Jitsi Meet for Android and iOS we
|
||||
// had recent-list's state as an object with property list.
|
||||
const { list } = state;
|
||||
|
||||
if (Array.isArray(list) && list.length) {
|
||||
return list.slice();
|
||||
}
|
||||
}
|
||||
|
||||
// In the weird case that we have previously persisted/serialized null.
|
||||
return DEFAULT_STATE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the recent room list that was stored using the legacy way.
|
||||
*
|
||||
* @returns {Array<Object>}
|
||||
*/
|
||||
function _getLegacyRecentRoomList(): Array<Object> {
|
||||
const str = jitsiLocalStorage.getItem(LEGACY_STORAGE_KEY);
|
||||
|
||||
if (str) {
|
||||
try {
|
||||
return Bourne.parse(str);
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse legacy recent-room list!');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new list entry to the redux store.
|
||||
*
|
||||
|
@ -184,8 +113,6 @@ function _updateConferenceDuration(state, { locationURL }) {
|
|||
duration: Date.now() - mostRecent.date
|
||||
};
|
||||
|
||||
delete nextMostRecent.conferenceDuration; // legacy
|
||||
|
||||
// Shallow copy to avoid in-place modification.
|
||||
const nextState = state.slice();
|
||||
|
||||
|
|
Loading…
Reference in New Issue