diff --git a/src/App.js b/src/App.js index a2f610d..bf97832 100644 --- a/src/App.js +++ b/src/App.js @@ -162,16 +162,9 @@ class App extends IPCContainer { } }; - onInstallDependencyComplete = (source, url, result) => { + onInstallDependencyComplete = () => { if (this._isMounted) { - if (result.Success && source.toLowerCase().endsWith('.dmg')) { - this.waitForDependencyInstall(source, url); - } else { - this.sendRequest(Constants.IPC_Delete_File, { - FilePath: source, - }); - this.checkVersionInstalled(); - } + this.checkVersionInstalled(); } }; @@ -215,27 +208,6 @@ class App extends IPCContainer { } }; - waitForDependencyInstall = (source, url) => { - const dep = this.props.MissingDependencies.find(d => { - return d.download === url; - }); - - const i = setInterval(()=> { - const ret = this.sendSyncRequest(Constants.IPC_Check_Dependency_Installed, { - File: dep.file, - }); - if (ret.data.Exists) { - clearInterval(i); - setTimeout(() => { - this.sendRequest(Constants.IPC_Delete_File, { - FilePath: source, - }); - this.checkVersionInstalled(); - }, 10000); - } - }, 3000); - }; - render() { const selectedVersion = this.getSelectedVersion(); diff --git a/src/redux/actions/install_actions.js b/src/redux/actions/install_actions.js index 5567a70..4a9bc65 100644 --- a/src/redux/actions/install_actions.js +++ b/src/redux/actions/install_actions.js @@ -59,8 +59,35 @@ export const installDependency = (source, url, completedCallback) => { const installDependencyComplete = (event, arg) => { ipcRenderer.removeListener(Constants.IPC_Install_Dependency_Reply, installDependencyComplete); - dispatch(setInstallComplete(arg.data)); - completedCallback(source, url, arg.data); + + const result = arg.data; + const handleCompleted = ()=> { + ipcRenderer.send(Constants.IPC_Delete_File, { + FilePath: source, + }); + dispatch(setInstallComplete(result)); + completedCallback(source, url, result); + }; + + if (result.Success && source.toLowerCase().endsWith('.dmg')) { + const dep = getState().install.MissingDependencies.find(d => { + return d.download === url; + }); + const i = setInterval(()=> { + const ret = ipcRenderer.sendSync(Constants.IPC_Check_Dependency_Installed + '_sync', { + File: dep.file, + }); + + if (ret.data.Exists) { + clearInterval(i); + setTimeout(() => { + handleCompleted(); + }, 5000); + } + }, 3000); + } else { + handleCompleted(); + } }; ipcRenderer.on(Constants.IPC_Install_Dependency_Reply, installDependencyComplete);