Prettier support

This commit is contained in:
2021-03-10 21:14:32 -06:00
parent c51b527707
commit 0924490a6f
99 changed files with 5504 additions and 3979 deletions

View File

@@ -1,18 +1,8 @@
import { createAction } from '@reduxjs/toolkit';
import * as Constants from '../../constants';
import {createAction} from '@reduxjs/toolkit';
import {
getIPCRenderer,
getSelectedVersionFromState
} from '../../utils';
import {notifyError} from './error_actions';
import {downloadItem, setAllowDownload} from './download_actions';
import {
loadReleases,
setActiveRelease,
setInstalledVersion,
setReleaseUpgradeAvailable,
setNewReleasesAvailable2,
} from './release_version_actions';
import { getIPCRenderer, getSelectedVersionFromState } from '../../utils.jsx';
import {
confirmYesNo,
displaySelectAppPlatform,
@@ -21,18 +11,28 @@ import {
setLinuxAppPlatform,
setRebootRequired,
showWindow,
shutdownApplication
shutdownApplication,
} from './common_actions';
import {unmountAll} from './mount_actions';
import { downloadItem, setAllowDownload } from './download_actions';
import { notifyError } from './error_actions';
import { unmountAll } from './mount_actions';
import {
loadReleases,
setActiveRelease,
setInstalledVersion,
setNewReleasesAvailable2,
setReleaseUpgradeAvailable,
} from './release_version_actions';
const ipcRenderer = getIPCRenderer();
export const checkInstalled = (dependencies, version) => {
return (dispatch, getState) => {
const checkInstalledComplete = (event, arg) => {
const checkInstalledComplete = (_, arg) => {
const result = arg.data;
const updateState = () => {
const installedVersion = result.Success && result.Exists ? result.Version : 'none';
const installedVersion =
result.Success && result.Exists ? result.Version : 'none';
const state = getState();
const release = state.relver.Release;
@@ -40,7 +40,9 @@ export const checkInstalled = (dependencies, version) => {
let upgradeAvailable = false;
if (installedVersion !== 'none') {
const latestVersion = state.relver.VersionLookup[Constants.RELEASE_TYPES[release]].length - 1;
const latestVersion =
state.relver.VersionLookup[Constants.RELEASE_TYPES[release]]
.length - 1;
if (version === -1) {
version = latestVersion;
dispatch(setActiveRelease(release, version));
@@ -57,14 +59,18 @@ export const checkInstalled = (dependencies, version) => {
const autoInstallRelease = getState().install.AutoInstallRelease;
dispatch(setAutoInstallRelease(false));
if (result.Dependencies && (result.Dependencies.length > 0)) {
if (result.Dependencies && result.Dependencies.length > 0) {
dispatch(showWindow());
} else if ((installedVersion === 'none') && autoInstallRelease) {
} else if (installedVersion === 'none' && autoInstallRelease) {
dispatch(setAllowMount(false));
const versionString = getState().relver.VersionLookup[Constants.RELEASE_TYPES[release]][version];
const versionString = getState().relver.VersionLookup[
Constants.RELEASE_TYPES[release]
][version];
const urls = getState().relver.LocationsLookup[versionString].urls;
const fileName = versionString + '.zip';
dispatch(downloadItem(fileName, Constants.INSTALL_TYPES.Release, urls));
dispatch(
downloadItem(fileName, Constants.INSTALL_TYPES.Release, urls)
);
}
};
@@ -75,7 +81,10 @@ export const checkInstalled = (dependencies, version) => {
}
};
ipcRenderer.once(Constants.IPC_Check_Installed_Reply, checkInstalledComplete);
ipcRenderer.once(
Constants.IPC_Check_Installed_Reply,
checkInstalledComplete
);
ipcRenderer.send(Constants.IPC_Check_Installed, {
Dependencies: dependencies,
Version: version,
@@ -89,10 +98,14 @@ export const checkVersionInstalled = () => {
dispatch(setAllowDownload(false));
const selectedVersion = getSelectedVersionFromState(state);
if (selectedVersion && (selectedVersion !== 'unavailable')) {
if (selectedVersion && selectedVersion !== 'unavailable') {
let dependencies = [];
if (state.relver.LocationsLookup[selectedVersion] && state.relver.LocationsLookup[selectedVersion].dependencies) {
dependencies = state.relver.LocationsLookup[selectedVersion].dependencies;
if (
state.relver.LocationsLookup[selectedVersion] &&
state.relver.LocationsLookup[selectedVersion].dependencies
) {
dependencies =
state.relver.LocationsLookup[selectedVersion].dependencies;
}
dispatch(checkInstalled(dependencies, selectedVersion));
} else {
@@ -107,9 +120,9 @@ export const installDependency = (source, url, isWinFSP) => {
if (ipcRenderer && !getState().install.InstallActive) {
dispatch(setInstallActive(Constants.INSTALL_TYPES.Dependency));
const installDependencyComplete = (event, arg) => {
const installDependencyComplete = (_, arg) => {
const result = arg.data;
const handleCompleted = ()=> {
const handleCompleted = () => {
if (result.RebootRequired) {
dispatch(setRebootRequired());
} else {
@@ -122,13 +135,16 @@ export const installDependency = (source, url, isWinFSP) => {
};
if (result.Success && source.toLowerCase().endsWith('.dmg')) {
const dep = getState().install.MissingDependencies.find(d => {
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,
});
const i = setInterval(() => {
const ret = ipcRenderer.sendSync(
Constants.IPC_Check_Dependency_Installed + '_sync',
{
File: dep.file,
}
);
if (ret.data.Exists) {
clearInterval(i);
@@ -142,7 +158,10 @@ export const installDependency = (source, url, isWinFSP) => {
}
};
ipcRenderer.once(Constants.IPC_Install_Dependency_Reply, installDependencyComplete);
ipcRenderer.once(
Constants.IPC_Install_Dependency_Reply,
installDependencyComplete
);
ipcRenderer.send(Constants.IPC_Install_Dependency, {
Source: source,
URL: url,
@@ -160,7 +179,7 @@ export const installAndTestRelease = (source, version, appPlatform) => {
FilePath: source,
});
ipcRenderer.once(Constants.IPC_Test_Release_Reply, (event, arg) => {
ipcRenderer.once(Constants.IPC_Test_Release_Reply, (_, arg) => {
if (arg.data.Success) {
ipcRenderer.sendSync(Constants.IPC_Set_Linux_AppPlatform, {
AppPlatform: appPlatform,
@@ -177,10 +196,13 @@ export const installAndTestRelease = (source, version, appPlatform) => {
});
ipcRenderer.send(Constants.IPC_Test_Release, {
Version: version,
})
});
};
ipcRenderer.once(Constants.IPC_Extract_Release_Complete, extractReleaseComplete);
ipcRenderer.once(
Constants.IPC_Extract_Release_Complete,
extractReleaseComplete
);
ipcRenderer.send(Constants.IPC_Extract_Release, {
Source: source,
Version: version,
@@ -192,7 +214,10 @@ export const installAndTestRelease = (source, version, appPlatform) => {
export const installReleaseByVersion = (release, version) => {
return (dispatch, getState) => {
const install = () => {
if (getState().download.AllowDownload && !getState().download.DownloadActive) {
if (
getState().download.AllowDownload &&
!getState().download.DownloadActive
) {
dispatch(setAutoInstallRelease(true));
dispatch(setActiveRelease(release, version));
} else {
@@ -202,31 +227,34 @@ export const installReleaseByVersion = (release, version) => {
if (getState().mounts.MountsBusy) {
dispatch(confirmYesNo('Unmount all drives?'))
.then(confirmed => {
.then((confirmed) => {
if (confirmed) {
dispatch(unmountAll(install));
}
})
.catch(error => notifyError(error));
.catch((error) => notifyError(error));
} else {
install();
}
};
};
export const installRelease = source => {
export const installRelease = (source) => {
return (dispatch, getState) => {
if (ipcRenderer && !getState().install.InstallActive) {
dispatch(setInstallActive(Constants.INSTALL_TYPES.Release));
const version = getSelectedVersionFromState(getState());
const extractReleaseComplete = (event, arg) => {
const extractReleaseComplete = (_, arg) => {
ipcRenderer.send(Constants.IPC_Delete_File, {
FilePath: source,
});
if (arg.data.Success) {
localStorage.setItem('previous_releases', localStorage.getItem('releases'));
localStorage.setItem(
'previous_releases',
localStorage.getItem('releases')
);
dispatch(setNewReleasesAvailable2([]));
}
@@ -234,7 +262,10 @@ export const installRelease = source => {
dispatch(checkVersionInstalled());
};
ipcRenderer.once(Constants.IPC_Extract_Release_Complete, extractReleaseComplete);
ipcRenderer.once(
Constants.IPC_Extract_Release_Complete,
extractReleaseComplete
);
ipcRenderer.send(Constants.IPC_Extract_Release, {
Source: source,
Version: version,
@@ -249,23 +280,33 @@ export const installUpgrade = (source, sha256, signature, skipVerification) => {
dispatch(setInstallActive(Constants.INSTALL_TYPES.Upgrade));
dispatch(setApplicationReady(false));
const installUpgradeComplete = (event, arg) => {
const installUpgradeComplete = (_, arg) => {
const result = arg.data;
if (result.Success) {
dispatch(shutdownApplication());
} else {
dispatch(setApplicationReady(true));
dispatch(setInstallComplete(result));
dispatch(notifyError(result.Error, false, () => {
// TODO Prompt to verify
if (result.AllowSkipVerification) {
dispatch(installUpgrade(source, sha256, signature, true));
}
}, false));
dispatch(
notifyError(
result.Error,
false,
() => {
// TODO Prompt to verify
if (result.AllowSkipVerification) {
dispatch(installUpgrade(source, sha256, signature, true));
}
},
false
)
);
}
};
ipcRenderer.once(Constants.IPC_Install_Upgrade_Reply, installUpgradeComplete);
ipcRenderer.once(
Constants.IPC_Install_Upgrade_Reply,
installUpgradeComplete
);
ipcRenderer.send(Constants.IPC_Install_Upgrade, {
Sha256: sha256,
Signature: signature,
@@ -276,9 +317,17 @@ export const installUpgrade = (source, sha256, signature, skipVerification) => {
};
};
export const setAutoInstallRelease = createAction('install/setAutoInstallRelease');
export const setDismissDependencies = createAction('install/setDismissDependencies');
export const setAutoInstallRelease = createAction(
'install/setAutoInstallRelease'
);
export const setDismissDependencies = createAction(
'install/setDismissDependencies'
);
export const setInstallActive = createAction('install/setInstallActive');
export const setInstallTestActive = createAction('install/setInstallTestActive');
export const setInstallTestActive = createAction(
'install/setInstallTestActive'
);
export const setInstallComplete = createAction('install/setInstallComplete');
export const setMissingDependencies = createAction('install/setMissingDependencies');
export const setMissingDependencies = createAction(
'install/setMissingDependencies'
);