Skip to content

Commit

Permalink
Also remove passing store
Browse files Browse the repository at this point in the history
  • Loading branch information
aaroncox committed Oct 19, 2023
1 parent 423ff11 commit 94bdcd2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
4 changes: 3 additions & 1 deletion app/main/main.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ const initSessionManager = async () => {
sHandler.manager.disconnect();
}
// Create new Session Manager
sHandler = new SessionManager(store);
const { sessions, settings } = store.getState();
sHandler = new SessionManager(sessions, settings);
// Connect the session manager
sHandler.manager.connect();
// Release the lock
Expand Down Expand Up @@ -431,3 +432,4 @@ global.initSessionManager = initSessionManager;
global.initHardwareLedger = initHardwareLedger;
global.showManager = showManager;
global.handleUri = data => handleUri(mainWindow, pHandler, data);
global.storeDispatch = data => store.dispatch(data);
26 changes: 4 additions & 22 deletions app/shared/utils/SessionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,15 @@ import WebSocket from 'ws';

import * as types from '../actions/types';

const { ipcRenderer } = require('electron');

export default class SessionManager {
handler: null;
// pHandler: null;
store: null;
storage: null;

constructor(store) {
constructor(sessions, settings) {
console.log('SessionManager::constructor');
// this.pHandler = pHandler;
this.store = store;
const { settings } = this.store.getState();
if (settings.walletMode !== 'cold') {
this.createHandler();
this.createStorage();
this.createStorage(sessions);
this.manager = new AnchorLinkSessionManager({
handler: this.handler,
storage: this.storage,
Expand Down Expand Up @@ -53,31 +46,20 @@ export default class SessionManager {
}
createHandler() {
console.log('SessionManager::createHandler');
const {
// pHandler,
store,
} = this;
// pHandler.webContents.send('sessionEvent', 'oncreate');
this.handler = {
onStorageUpdate(json) {
const storage = JSON.parse(json);
store.dispatch({
global.storeDispatch({
type: types.SYSTEM_SESSIONS_SYNC,
payload: storage,
});
},
onIncomingRequest(payload) {
global.handleUri(payload);
},
// onSocketEvent(type, event) {
// if (pHandler && pHandler.webContents) {
// pHandler.webContents.send('sessionEvent', type, JSON.stringify(event));
// }
// },
};
}
createStorage() {
const { sessions } = this.store.getState();
createStorage(sessions) {
if (sessions && sessions.requestKey && sessions.linkId) {
const json = JSON.stringify(sessions);
this.storage = AnchorLinkSessionManagerStorage.unserialize(json);
Expand Down

0 comments on commit 94bdcd2

Please sign in to comment.