Handle release unavailable

This commit is contained in:
Scott E. Graves
2019-07-24 14:09:11 -05:00
parent 763bf4491d
commit 37607bf152
5 changed files with 56 additions and 9 deletions

View File

@@ -72,6 +72,12 @@ function setWindowVisibility(show) {
}
const unmountAllDrives = () => {
// Reset mount states
for (const provider of Constants.PROVIDER_LIST) {
clearManualMountDetection(provider);
expectedUnmount[provider] = true;
}
// Unmount all items
for (const i in mountedLocations) {
const data = mountedData[mountedLocations[i]];
@@ -898,16 +904,21 @@ ipcMain.on(Constants.IPC_Show_Window + '_sync', event => {
event.returnValue = true;
});
ipcMain.on(Constants.IPC_Unmount_All_Drives, (event, data) => {
unmountAllDrives();
standardIPCReply(event, Constants.IPC_Unmount_All_Drives_Reply);
});
ipcMain.on(Constants.IPC_Unmount_Drive, (event, data) => {
clearManualMountDetection(data.Provider);
expectedUnmount[data.Provider] = true;
helpers
.stopMountProcess(data.Version, data.Provider)
.then((result)=> {
.then(result => {
console.log(result);
})
.catch((e) => {
.catch(e => {
console.log(e);
});
});

View File

@@ -114,5 +114,8 @@ exports.IPC_Set_Config_Values_Reply = 'set_config_values_reply';
exports.IPC_Shutdown = 'shutdown';
exports.IPC_Unmount_All_Drives = 'unmount_all';
exports.IPC_Unmount_All_Drives_Reply = 'unmount_all_reply';
exports.IPC_Unmount_Drive = 'unmount_drive';
exports.IPC_Unmount_Drive_Reply = 'unmount_drive_reply';

View File

@@ -1,4 +1,6 @@
import * as Constants from '../../constants';
import {createAction} from 'redux-starter-kit';
import {getIPCRenderer} from '../../utils';
export const displayConfiguration = createAction('mounts/displayConfiguration');
@@ -9,6 +11,7 @@ export const resetMountsState = () => {
payload: null,
}
};
export const SET_ALLOW_MOUNT = 'mounts/setAllowMount';
export const setAllowMount = (provider, allow) => {
return {
@@ -55,3 +58,15 @@ export const setProviderState = (provider, state) => {
}
}
};
export const unmountAll = completedCallback => {
return (dispatch, getState) => {
const ipcRenderer = getIPCRenderer();
const unmountedCallback = () => {
dispatch(resetMountsState());
completedCallback();
};
ipcRenderer.once(Constants.IPC_Unmount_All_Drives_Reply, unmountedCallback);
ipcRenderer.send(Constants.IPC_Unmount_All_Drives);
}
};

View File

@@ -3,9 +3,11 @@ import * as Constants from '../../constants';
import {createAction} from 'redux-starter-kit';
import {notifyError} from './error_actions';
import {
saveState,
setApplicationReady,
showWindow
} from './common_actions';
import {unmountAll} from './mount_actions';
export const CLEAR_UI_UPGRADE = 'relver/clearUIUpgrade';
export const clearUIUpgrade = () => {
@@ -47,19 +49,34 @@ export const loadReleases = () => {
return (dispatch, getState) => {
const dispatchActions = (locationsLookup, versionLookup)=> {
const state = getState().relver;
const latestVersion = versionLookup[Constants.RELEASE_TYPES[state.Release]].length - 1;
let latestVersion = versionLookup[Constants.RELEASE_TYPES[state.Release]].length - 1;
let release = state.Release;
let version = state.Version;
if ((version === -1) || !versionLookup[Constants.RELEASE_TYPES[state.Release]][version]) {
if (versionLookup[Constants.RELEASE_TYPES[release]][0] === 'unavailable') {
release = state.ReleaseDefault;
latestVersion = version = 0;
} else if ((version === -1) || !versionLookup[Constants.RELEASE_TYPES[state.Release]][version]) {
version = latestVersion;
}
dispatch(setReleaseData(locationsLookup, versionLookup));
if (version !== state.Version) {
dispatch(setActiveRelease(state.Release, version));
const dispatchActions = () => {
dispatch(setReleaseUpgradeAvailable((version !== latestVersion)));
dispatch(setApplicationReady(true));
dispatch(detectUIUpgrade());
};
if ((version !== state.Version) || (release !== state.Release)) {
dispatch(unmountAll(() => {
dispatch(setActiveRelease(release, version));
dispatchActions();
dispatch(showWindow());
dispatch(saveState());
}));
} else {
dispatchActions();
}
dispatch(setReleaseUpgradeAvailable((version !== latestVersion)));
dispatch(setApplicationReady(true));
dispatch(detectUIUpgrade());
};
axios

View File

@@ -17,6 +17,7 @@ export const releaseVersionReducer = createReducer({
InstalledVersion: 'none',
LocationsLookup: {},
Release: 0,
ReleaseDefault: 0,
ReleaseUpgradeAvailable: false,
UpgradeAvailable: false,
UpgradeData: null,