@@ -2,10 +2,9 @@ import * as ConfigGen from '../config-gen'
22import * as ConfigConstants from '../../constants/config'
33import * as EngineGen from '../engine-gen-gen'
44import * as RPCTypes from '../../constants/types/rpc-gen'
5- import * as SafeElectron from '../../util/safe- electron.desktop '
5+ import * as Electron from 'electron'
66import * as Saga from '../../util/saga'
77import logger from '../../logger'
8- import path from 'path'
98import { NotifyPopup } from '../../native/notifications'
109import { execFile } from 'child_process'
1110import { getEngine } from '../../engine'
@@ -17,6 +16,9 @@ import InputMonitor from './input-monitor.desktop'
1716import { skipAppFocusActions } from '../../local-debug.desktop'
1817import * as Container from '../../util/container'
1918
19+ const { resolve} = KB . path
20+ const { argv, env, pid} = KB . process
21+
2022export function showShareActionSheet ( ) {
2123 throw new Error ( 'Show Share Action - unsupported on this platform' )
2224}
@@ -28,7 +30,7 @@ export async function saveAttachmentToCameraRoll() {
2830}
2931
3032const showMainWindow = ( ) => {
31- SafeElectron . getApp ( ) . emit ( 'KBkeybase' , ' ', { type : 'showMainWindow' } )
33+ Electron . ipcRenderer . invoke ( 'KBkeybase' , { type : 'showMainWindow' } )
3234}
3335
3436export function displayNewMessageNotification ( ) {
@@ -77,7 +79,7 @@ function* initializeInputMonitor(): Iterable<any> {
7779 const userActive = type === 'active'
7880 yield Saga . put ( ConfigGen . createChangedActive ( { userActive} ) )
7981 // let node thread save file
80- SafeElectron . getApp ( ) . emit ( 'KBkeybase' , ' ', {
82+ Electron . ipcRenderer . invoke ( 'KBkeybase' , {
8183 payload : { changedAtMs : Date . now ( ) , isUserActive : userActive } ,
8284 type : 'activeChanged' ,
8385 } )
@@ -87,7 +89,7 @@ function* initializeInputMonitor(): Iterable<any> {
8789
8890export const dumpLogs = async ( action ?: ConfigGen . DumpLogsPayload ) => {
8991 const fromRender = await logger . dump ( )
90- const globalLogger : typeof logger = SafeElectron . getRemote ( ) . getGlobal ( 'globalLogger' )
92+ const globalLogger : typeof logger = Electron . remote . getGlobal ( 'globalLogger' )
9193 const fromMain = await globalLogger . dump ( )
9294 await writeLogLinesToFile ( [ ...fromRender , ...fromMain ] )
9395 // quit as soon as possible
@@ -104,8 +106,8 @@ function* checkRPCOwnership(_: Container.TypedState, action: ConfigGen.DaemonHan
104106 try {
105107 logger . info ( 'Checking RPC ownership' )
106108
107- const localAppData = String ( process . env . LOCALAPPDATA )
108- var binPath = localAppData ? path . resolve ( localAppData , 'Keybase' , 'keybase.exe' ) : 'keybase.exe'
109+ const localAppData = String ( env . LOCALAPPDATA )
110+ var binPath = localAppData ? resolve ( localAppData , 'Keybase' , 'keybase.exe' ) : 'keybase.exe'
109111 const args = [ 'pipeowner' , socketPath ]
110112 yield Saga . callUntyped (
111113 ( ) =>
@@ -168,7 +170,7 @@ function* setupReachabilityWatcher() {
168170
169171const onExit = ( ) => {
170172 console . log ( 'App exit requested' )
171- SafeElectron . getApp ( ) . exit ( 0 )
173+ Electron . remote . app . exit ( 0 )
172174}
173175
174176const onFSActivity = ( state : Container . TypedState , action : EngineGen . Keybase1NotifyFSFSActivityPayload ) => {
@@ -185,18 +187,18 @@ const onShutdown = (action: EngineGen.Keybase1NotifyServiceShutdownPayload) => {
185187 if ( isWindows && code !== RPCTypes . ExitCode . restart ) {
186188 console . log ( 'Quitting due to service shutdown with code: ' , code )
187189 // Quit just the app, not the service
188- SafeElectron . getApp ( ) . quit ( )
190+ Electron . remote . app . quit ( )
189191 }
190192}
191193
192194const onConnected = ( ) => {
193195 // Introduce ourselves to the service
194196 RPCTypes . configHelloIAmRpcPromise ( {
195197 details : {
196- argv : process . argv ,
198+ argv : argv ,
197199 clientType : RPCTypes . ClientType . guiMain ,
198200 desc : 'Main Renderer' ,
199- pid : SafeElectron . getRemote ( ) . process . pid ,
201+ pid,
200202 version : __VERSION__ , // eslint-disable-line no-undef
201203 } ,
202204 } ) . catch ( _ => { } )
@@ -221,7 +223,7 @@ const prepareLogSend = async (action: EngineGen.Keybase1LogsendPrepareLogsendPay
221223}
222224
223225const copyToClipboard = ( action : ConfigGen . CopyToClipboardPayload ) => {
224- SafeElectron . getClipboard ( ) . writeText ( action . payload . text )
226+ Electron . clipboard . writeText ( action . payload . text )
225227}
226228
227229const sendWindowsKBServiceCheck = (
@@ -234,7 +236,7 @@ const sendWindowsKBServiceCheck = (
234236 state . config . daemonHandshakeWaiters . size === 0 &&
235237 state . config . daemonHandshakeFailedReason === ConfigConstants . noKBFSFailReason
236238 ) {
237- SafeElectron . getApp ( ) . emit ( 'keybase' as any , { type : 'requestWindowsStartService' } )
239+ Electron . ipcRenderer . invoke ( 'KBkeybase' , { type : 'requestWindowsStartService' } )
238240 }
239241}
240242
@@ -277,7 +279,7 @@ const updateNow = async () => {
277279
278280function * startPowerMonitor ( ) {
279281 const channel = Saga . eventChannel ( emitter => {
280- const pm = SafeElectron . getPowerMonitor ( )
282+ const pm = Electron . remote . powerMonitor
281283 pm . on ( 'suspend' , ( ) => emitter ( 'suspend' ) )
282284 pm . on ( 'resume' , ( ) => emitter ( 'resume' ) )
283285 pm . on ( 'shutdown' , ( ) => emitter ( 'shutdown' ) )
@@ -391,9 +393,9 @@ const setOpenAtLogin = async (state: Container.TypedState) => {
391393 ( await RPCTypes . ctlGetNixOnLoginStartupRpcPromise ( ) ) === RPCTypes . OnLoginStartupStatus . enabled
392394 if ( enabled !== openAtLogin ) await setNixOnLoginStartup ( openAtLogin )
393395 } else {
394- if ( SafeElectron . getApp ( ) . getLoginItemSettings ( ) . openAtLogin !== openAtLogin ) {
396+ if ( Electron . remote . app . getLoginItemSettings ( ) . openAtLogin !== openAtLogin ) {
395397 logger . info ( `Login item settings changed! now ${ openAtLogin } ` )
396- SafeElectron . getApp ( ) . setLoginItemSettings ( { openAtLogin} )
398+ Electron . remote . app . setLoginItemSettings ( { openAtLogin} )
397399 }
398400 }
399401}
0 commit comments