Browse Source

refactor: Remove electron-store to be ready for electron 14+ (#668)

Release this ~3 months after 2.9.0 was released (21 Sep 2021) so
that users had 3 months to migrate to local storage

Signed-off-by: Christoph Settgast <csett86@web.de>
master
csett86 6 months ago committed by GitHub
parent
commit
94f39ce107
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      app/features/redux/store.js
  2. 3
      app/preload/preload.js
  3. 4
      main.js
  4. 545
      package-lock.json
  5. 2
      package.json

25
app/features/redux/store.js

@ -1,37 +1,14 @@
// @flow
import { createStore } from 'redux';
import { persistReducer, getStoredState } from 'redux-persist';
import { persistReducer } 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',
// 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',

3
app/preload/preload.js

@ -1,6 +1,5 @@
/* global process */
const createElectronStorage = require('redux-persist-electron-storage');
const { ipcRenderer } = require('electron');
const os = require('os');
const jitsiMeetElectronUtils = require('@jitsi/electron-sdk');
@ -10,12 +9,10 @@ const { openExternalLink } = require('../features/utils/openExternalLink');
const whitelistedIpcChannels = [ 'protocol-data-msg', 'renderer-ready' ];
window.jitsiNodeAPI = {
createElectronStorage,
osUserInfo: os.userInfo,
openExternalLink,
platform: process.platform,
jitsiMeetElectronUtils,
electronStoreExists: ipcRenderer.sendSync('electron-store-exists'),
ipc: {
on: (channel, listener) => {
if (!whitelistedIpcChannels.includes(channel)) {

4
main.js

@ -399,7 +399,3 @@ ipcMain.on('renderer-ready', () => {
.send('protocol-data-msg', protocolDataForFrontApp);
}
});
ipcMain.on('electron-store-exists', event => {
event.returnValue = existsSync(path.join(app.getPath('userData'), 'config.json'));
});

545
package-lock.json generated

File diff suppressed because it is too large Load Diff

2
package.json

@ -167,7 +167,6 @@
"electron-log": "^4.3.2",
"electron-notarize": "1.1.1",
"electron-react-devtools": "0.5.3",
"electron-store": "^5.2.0",
"electron-updater": "^4.3.9",
"electron-window-state": "^5.0.3",
"eslint": "6.5.1",
@ -192,7 +191,6 @@
"redux": "^4.0.5",
"redux-logger": "^3.0.6",
"redux-persist": "^5.10.0",
"redux-persist-electron-storage": "^2.1.0",
"source-map-support": "^0.5.19",
"style-loader": "1.1.3",
"styled-components": "^3.4.10",

Loading…
Cancel
Save