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 = () => { const unmountAllDrives = () => {
// Reset mount states
for (const provider of Constants.PROVIDER_LIST) {
clearManualMountDetection(provider);
expectedUnmount[provider] = true;
}
// Unmount all items // Unmount all items
for (const i in mountedLocations) { for (const i in mountedLocations) {
const data = mountedData[mountedLocations[i]]; const data = mountedData[mountedLocations[i]];
@@ -898,16 +904,21 @@ ipcMain.on(Constants.IPC_Show_Window + '_sync', event => {
event.returnValue = true; 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) => { ipcMain.on(Constants.IPC_Unmount_Drive, (event, data) => {
clearManualMountDetection(data.Provider); clearManualMountDetection(data.Provider);
expectedUnmount[data.Provider] = true; expectedUnmount[data.Provider] = true;
helpers helpers
.stopMountProcess(data.Version, data.Provider) .stopMountProcess(data.Version, data.Provider)
.then((result)=> { .then(result => {
console.log(result); console.log(result);
}) })
.catch((e) => { .catch(e => {
console.log(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_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 = 'unmount_drive';
exports.IPC_Unmount_Drive_Reply = 'unmount_drive_reply'; 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 {createAction} from 'redux-starter-kit';
import {getIPCRenderer} from '../../utils';
export const displayConfiguration = createAction('mounts/displayConfiguration'); export const displayConfiguration = createAction('mounts/displayConfiguration');
@@ -9,6 +11,7 @@ export const resetMountsState = () => {
payload: null, payload: null,
} }
}; };
export const SET_ALLOW_MOUNT = 'mounts/setAllowMount'; export const SET_ALLOW_MOUNT = 'mounts/setAllowMount';
export const setAllowMount = (provider, allow) => { export const setAllowMount = (provider, allow) => {
return { 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 {createAction} from 'redux-starter-kit';
import {notifyError} from './error_actions'; import {notifyError} from './error_actions';
import { import {
saveState,
setApplicationReady, setApplicationReady,
showWindow showWindow
} from './common_actions'; } from './common_actions';
import {unmountAll} from './mount_actions';
export const CLEAR_UI_UPGRADE = 'relver/clearUIUpgrade'; export const CLEAR_UI_UPGRADE = 'relver/clearUIUpgrade';
export const clearUIUpgrade = () => { export const clearUIUpgrade = () => {
@@ -47,21 +49,36 @@ export const loadReleases = () => {
return (dispatch, getState) => { return (dispatch, getState) => {
const dispatchActions = (locationsLookup, versionLookup)=> { const dispatchActions = (locationsLookup, versionLookup)=> {
const state = getState().relver; 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; 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; version = latestVersion;
} }
dispatch(setReleaseData(locationsLookup, versionLookup)); dispatch(setReleaseData(locationsLookup, versionLookup));
if (version !== state.Version) {
dispatch(setActiveRelease(state.Release, version)); const dispatchActions = () => {
}
dispatch(setReleaseUpgradeAvailable((version !== latestVersion))); dispatch(setReleaseUpgradeAvailable((version !== latestVersion)));
dispatch(setApplicationReady(true)); dispatch(setApplicationReady(true));
dispatch(detectUIUpgrade()); dispatch(detectUIUpgrade());
}; };
if ((version !== state.Version) || (release !== state.Release)) {
dispatch(unmountAll(() => {
dispatch(setActiveRelease(release, version));
dispatchActions();
dispatch(showWindow());
dispatch(saveState());
}));
} else {
dispatchActions();
}
};
axios axios
.get(Constants.RELEASES_URL) .get(Constants.RELEASES_URL)
.then(response => { .then(response => {

View File

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