[#27: Implement Bitbucket backup download location] [Prefer 'ipcRenderer.once()']

This commit is contained in:
Scott E. Graves
2019-07-05 19:21:54 -05:00
parent e8b743ae0b
commit 7c54747a7a
3 changed files with 43 additions and 37 deletions

View File

@@ -18,7 +18,6 @@ const ipcRenderer = getIPCRenderer();
export const checkInstalled = (dependencies, version) => {
return (dispatch, getState) => {
const checkInstalledComplete = (event, arg) => {
ipcRenderer.removeListener(Constants.IPC_Check_Installed_Reply, checkInstalledComplete);
const result = arg.data;
const updateState = () => {
const installedVersion = result.Success && result.Exists ? result.Version : 'none';
@@ -48,7 +47,7 @@ export const checkInstalled = (dependencies, version) => {
}
};
ipcRenderer.on(Constants.IPC_Check_Installed_Reply, checkInstalledComplete);
ipcRenderer.once(Constants.IPC_Check_Installed_Reply, checkInstalledComplete);
ipcRenderer.send(Constants.IPC_Check_Installed, {
Dependencies: dependencies,
Version: version,
@@ -62,8 +61,6 @@ export const installDependency = (source, url, completedCallback) => {
dispatch(setInstallActive(Constants.INSTALL_TYPES.Dependency));
const installDependencyComplete = (event, arg) => {
ipcRenderer.removeListener(Constants.IPC_Install_Dependency_Reply, installDependencyComplete);
const result = arg.data;
const handleCompleted = ()=> {
ipcRenderer.send(Constants.IPC_Delete_File, {
@@ -94,7 +91,7 @@ export const installDependency = (source, url, completedCallback) => {
}
};
ipcRenderer.on(Constants.IPC_Install_Dependency_Reply, installDependencyComplete);
ipcRenderer.once(Constants.IPC_Install_Dependency_Reply, installDependencyComplete);
ipcRenderer.send(Constants.IPC_Install_Dependency, {
Source: source,
URL: url,
@@ -109,7 +106,6 @@ export const installRelease = (source, version, completedCallback) => {
dispatch(setInstallActive(Constants.INSTALL_TYPES.Release));
const extractReleaseComplete = (event, arg) => {
ipcRenderer.removeListener(Constants.IPC_Extract_Release_Complete, extractReleaseComplete);
ipcRenderer.send(Constants.IPC_Delete_File, {
FilePath: source,
});
@@ -118,7 +114,7 @@ export const installRelease = (source, version, completedCallback) => {
completedCallback(source, version, arg.data);
};
ipcRenderer.on(Constants.IPC_Extract_Release_Complete, extractReleaseComplete);
ipcRenderer.once(Constants.IPC_Extract_Release_Complete, extractReleaseComplete);
ipcRenderer.send(Constants.IPC_Extract_Release, {
Source: source,
Version: version,
@@ -134,7 +130,6 @@ export const installUpgrade = (source, sha256, signature, skipVerification, comp
dispatch(setApplicationReady(false));
const installUpgradeComplete = (event, arg) => {
ipcRenderer.removeListener(Constants.IPC_Install_Upgrade_Reply, installUpgradeComplete);
if (arg.data.Success) {
dispatch(shutdownApplication());
} else {
@@ -144,7 +139,7 @@ export const installUpgrade = (source, sha256, signature, skipVerification, comp
}
};
ipcRenderer.on(Constants.IPC_Install_Upgrade_Reply, installUpgradeComplete);
ipcRenderer.once(Constants.IPC_Install_Upgrade_Reply, installUpgradeComplete);
ipcRenderer.send(Constants.IPC_Install_Upgrade, {
Sha256: sha256,
Signature: signature,