aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorcsett86 <csett86@web.de>2021-09-20 10:40:27 +0200
committerGitHub <noreply@github.com>2021-09-20 10:40:27 +0200
commit295ea6d1ecc485f7980740add37dca0e7678c9f1 (patch)
treefde1701d241a273f2540f033cd953ee8eb19ae86 /app
parent9c13108eb32d34e58f0db0829e17b59e3b32a0b9 (diff)
Switch to local storage and migrate old settings (#638)
This is a preparation for electron 14+, where electron-store is no longer in a usable state (currently used version does not work due to remote module removed in electron 14, latest version extends every app startup to 10 seconds). Once sufficient migration period has passed, electron-store and redux-persist-electron-storage and the ipc call introduced here (electron-store-exists) can be removed.
Diffstat (limited to 'app')
-rw-r--r--app/features/redux/store.js28
-rw-r--r--app/preload/preload.js1
2 files changed, 27 insertions, 2 deletions
diff --git a/app/features/redux/store.js b/app/features/redux/store.js
index 3700012..4af76d1 100644
--- a/app/features/redux/store.js
+++ b/app/features/redux/store.js
@@ -1,14 +1,38 @@
// @flow
import { createStore } from 'redux';
-import { persistReducer } from 'redux-persist';
+import { persistReducer, getStoredState } from 'redux-persist';
+import storage from 'redux-persist/lib/storage'; // uses localStorage
import middleware from './middleware';
import reducers from './reducers';
+const migrateFromElectronStore = async state => {
+ // migrate to local storage by checking if state is undefined
+ // (first launch or first launch after switch to local storage)
+ // and previous electron-store config.json exists.
+ if (state === undefined && window.jitsiNodeAPI.electronStoreExists) {
+ const electronStoreState = await getStoredState({
+ key: 'root',
+ storage: window.jitsiNodeAPI.createElectronStorage(),
+ debug: true
+ });
+
+ if ('onboarding' in electronStoreState) {
+ return electronStoreState;
+ }
+ }
+
+ return state;
+};
+
const persistConfig = {
key: 'root',
- storage: window.jitsiNodeAPI.createElectronStorage(),
+
+ // remove this and all electron-store-related dependencies end of 2021
+ // (3 months migration period from electron-store to local storage)
+ migrate: migrateFromElectronStore,
+ storage,
whitelist: [
'onboarding',
'recentList',
diff --git a/app/preload/preload.js b/app/preload/preload.js
index 54bf79b..5693c86 100644
--- a/app/preload/preload.js
+++ b/app/preload/preload.js
@@ -15,6 +15,7 @@ window.jitsiNodeAPI = {
openExternalLink,
platform: process.platform,
jitsiMeetElectronUtils,
+ electronStoreExists: ipcRenderer.sendSync('electron-store-exists'),
ipc: {
on: (channel, listener) => {
if (!whitelistedIpcChannels.includes(channel)) {