mirror of https://github.com/keeweb/keeweb
reorganized imports a bit
This commit is contained in:
parent
5bbc9003f4
commit
b4f93adf05
|
@ -1,11 +1,6 @@
|
|||
import { Launcher } from 'comp/launcher';
|
||||
import { Logger } from 'util/logger';
|
||||
import {
|
||||
ProtocolHandlers,
|
||||
initProtocolImpl,
|
||||
cleanupProtocolImpl,
|
||||
deleteProtocolImplConnection
|
||||
} from './protocol-impl';
|
||||
import { ProtocolHandlers, ProtocolImpl } from './protocol-impl';
|
||||
import { RuntimeInfo } from 'const/runtime-info';
|
||||
import { AppSettingsModel } from 'models/app-settings-model';
|
||||
import { Features } from 'util/features';
|
||||
|
@ -40,7 +35,7 @@ const BrowserExtensionConnector = {
|
|||
|
||||
init(appModel) {
|
||||
const sendEvent = this.sendEvent.bind(this);
|
||||
initProtocolImpl({ appModel, logger, sendEvent });
|
||||
ProtocolImpl.init({ appModel, logger, sendEvent });
|
||||
|
||||
this.browserWindowMessage = this.browserWindowMessage.bind(this);
|
||||
|
||||
|
@ -75,7 +70,7 @@ const BrowserExtensionConnector = {
|
|||
this.stopWebMessageListener();
|
||||
}
|
||||
|
||||
cleanupProtocolImpl();
|
||||
ProtocolImpl.cleanup();
|
||||
connections.clear();
|
||||
|
||||
logger.info('Stopped');
|
||||
|
@ -198,7 +193,7 @@ const BrowserExtensionConnector = {
|
|||
|
||||
socketClosed(socketId) {
|
||||
connections.delete(socketId);
|
||||
deleteProtocolImplConnection(socketId);
|
||||
ProtocolImpl.deleteConnection(socketId);
|
||||
},
|
||||
|
||||
async socketRequest(socketId, request) {
|
||||
|
|
|
@ -29,25 +29,27 @@ let logger;
|
|||
let appModel;
|
||||
let sendEvent;
|
||||
|
||||
function initProtocolImpl(vars) {
|
||||
appModel = vars.appModel;
|
||||
logger = vars.logger;
|
||||
sendEvent = vars.sendEvent;
|
||||
const ProtocolImpl = {
|
||||
init(vars) {
|
||||
appModel = vars.appModel;
|
||||
logger = vars.logger;
|
||||
sendEvent = vars.sendEvent;
|
||||
|
||||
setupListeners();
|
||||
}
|
||||
setupListeners();
|
||||
},
|
||||
|
||||
function cleanupProtocolImpl() {
|
||||
connectedClients.clear();
|
||||
}
|
||||
cleanup() {
|
||||
connectedClients.clear();
|
||||
},
|
||||
|
||||
function deleteProtocolImplConnection(connectionId) {
|
||||
for (const client of connectedClients.values()) {
|
||||
if (client.connection.connectionId === connectionId) {
|
||||
connectedClients.delete(client);
|
||||
deleteConnection(connectionId) {
|
||||
for (const client of connectedClients.values()) {
|
||||
if (client.connection.connectionId === connectionId) {
|
||||
connectedClients.delete(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function setupListeners() {
|
||||
Events.on('file-opened', () => {
|
||||
|
@ -406,4 +408,4 @@ const ProtocolHandlers = {
|
|||
}
|
||||
};
|
||||
|
||||
export { ProtocolHandlers, initProtocolImpl, cleanupProtocolImpl, deleteProtocolImplConnection };
|
||||
export { ProtocolHandlers, ProtocolImpl };
|
||||
|
|
Loading…
Reference in New Issue