diff --git a/app/ui/window.js b/app/ui/window.js index 6cba8cd1..96815e62 100644 --- a/app/ui/window.js +++ b/app/ui/window.js @@ -129,35 +129,8 @@ module.exports = class Window { return {session, options}; } - // Optimistically create the initial session so that when the window sends - // the first "new" IPC message, there's a session already warmed up. - let initialSession = null; - function createInitialSession() { - let {session, options} = createSession(); - const initialEvents = []; - const handleData = data => initialEvents.push(['session data', data]); - const handleExit = () => { - // the warmed up session should be cleaned if exit before add a new session. - session.removeListener('data', handleData); - session.removeListener('exit', handleExit); - initialSession = null; - }; - session.on('data', handleData); - session.on('exit', handleExit); - - function flushEvents() { - for (let args of initialEvents) { - rpc.emit(...args); - } - session.removeListener('data', handleData); - session.removeListener('exit', handleExit); - } - return {session, options, flushEvents}; - } - initialSession = createInitialSession(); - rpc.on('new', extraOptions => { - const {session, options} = initialSession || createSession(extraOptions); + const {session, options} = createSession(extraOptions); sessions.set(options.uid, session); rpc.emit('session add', { @@ -170,13 +143,6 @@ module.exports = class Window { activeUid: options.activeUid }); - // If this is the initial session, flush any events that might have - // occurred while the window was initializing - if (initialSession) { - initialSession.flushEvents(); - initialSession = null; - } - session.on('data', data => { rpc.emit('session data', data); });