SiaPrime support
This commit is contained in:
32
electron.js
32
electron.js
@@ -21,7 +21,7 @@ let mountedPIDs = [];
|
|||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
// Create the browser window.
|
// Create the browser window.
|
||||||
const height = process.env.ELECTRON_START_URL ? 324 : 304;
|
const height = process.env.ELECTRON_START_URL ? 404 : 384;
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 425,
|
width: 425,
|
||||||
height: height,
|
height: height,
|
||||||
@@ -191,16 +191,18 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
|||||||
let driveLetters = {
|
let driveLetters = {
|
||||||
Hyperspace: [],
|
Hyperspace: [],
|
||||||
Sia: [],
|
Sia: [],
|
||||||
|
SiaPrime: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
const grabDriveLetters = (hsLocation, siaLocation) => {
|
const grabDriveLetters = (hsLocation, siaLocation, siaPrimeLocation) => {
|
||||||
for (let i = 'c'.charCodeAt(0); i <= 'z'.charCodeAt(0); i++) {
|
for (let i = 'c'.charCodeAt(0); i <= 'z'.charCodeAt(0); i++) {
|
||||||
const drive = (String.fromCharCode(i) + ':').toUpperCase();
|
const drive = (String.fromCharCode(i) + ':').toUpperCase();
|
||||||
if (!(hsLocation.startsWith(drive) || siaLocation.startsWith(drive))) {
|
if (!(hsLocation.startsWith(drive) || siaLocation.startsWith(drive) || siaPrimeLocation.startsWith(drive))) {
|
||||||
try {
|
try {
|
||||||
if (!fs.existsSync(drive)) {
|
if (!fs.existsSync(drive)) {
|
||||||
driveLetters.Hyperspace.push(drive);
|
driveLetters.Hyperspace.push(drive);
|
||||||
driveLetters.Sia.push(drive);
|
driveLetters.Sia.push(drive);
|
||||||
|
driveLetters.SiaPrime.push(drive);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
}
|
}
|
||||||
@@ -222,17 +224,21 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
|||||||
driveLetters.Sia.push(siaLocation);
|
driveLetters.Sia.push(siaLocation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (siaPrimeLocation.length > 0) {
|
||||||
|
if (!driveLetters.SiaPrime.find((driveLetter) => {
|
||||||
|
return driveLetter === siaPrimeLocation;
|
||||||
|
})) {
|
||||||
|
driveLetters.SiaPrime.push(siaPrimeLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const setImage = (hsLocation, siaLocation) => {
|
const setImage = (hsLocation, siaLocation, siaPrimeLocation) => {
|
||||||
if (os.platform() === 'win32') {
|
if (os.platform() === 'win32') {
|
||||||
let image;
|
let image;
|
||||||
if ((siaLocation.length > 0) && (hsLocation.length > 0)) {
|
if ((siaLocation.length > 0) || (hsLocation.length > 0) || (siaPrimeLocation.length > 0)) {
|
||||||
image = nativeImage.createFromPath(path.join(__dirname, '/build/logo_both.png'));
|
image = nativeImage.createFromPath(path.join(__dirname, '/build/logo_both.png'));
|
||||||
} else if (hsLocation.length > 0) {
|
|
||||||
image = nativeImage.createFromPath(path.join(__dirname, '/build/logo_hs.png'));
|
|
||||||
} else if (siaLocation.length > 0) {
|
|
||||||
image = nativeImage.createFromPath(path.join(__dirname, '/build/logo_sia.png'));
|
|
||||||
} else {
|
} else {
|
||||||
image = nativeImage.createFromPath(path.join(__dirname, '/build/logo.png'));
|
image = nativeImage.createFromPath(path.join(__dirname, '/build/logo.png'));
|
||||||
}
|
}
|
||||||
@@ -247,21 +253,25 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
|||||||
.then((results) => {
|
.then((results) => {
|
||||||
let hsLocation = results.Hyperspace.Location;
|
let hsLocation = results.Hyperspace.Location;
|
||||||
let siaLocation = results.Sia.Location;
|
let siaLocation = results.Sia.Location;
|
||||||
|
let siaPrimeLocation = results.SiaPrime.Location;
|
||||||
if (os.platform() === 'win32') {
|
if (os.platform() === 'win32') {
|
||||||
hsLocation = hsLocation.toUpperCase();
|
hsLocation = hsLocation.toUpperCase();
|
||||||
siaLocation = siaLocation.toUpperCase();
|
siaLocation = siaLocation.toUpperCase();
|
||||||
grabDriveLetters(hsLocation, siaLocation);
|
siaPrimeLocation = siaPrimeLocation.toUpperCase();
|
||||||
|
grabDriveLetters(hsLocation, siaLocation, siaPrimeLocation);
|
||||||
}
|
}
|
||||||
setImage(hsLocation, siaLocation);
|
setImage(hsLocation, siaLocation, siaPrimeLocation);
|
||||||
standardIPCReply(event, Constants.IPC_Detect_Mounts_Reply, {
|
standardIPCReply(event, Constants.IPC_Detect_Mounts_Reply, {
|
||||||
DriveLetters: driveLetters,
|
DriveLetters: driveLetters,
|
||||||
Locations: {
|
Locations: {
|
||||||
Hyperspace: hsLocation,
|
Hyperspace: hsLocation,
|
||||||
Sia: siaLocation,
|
Sia: siaLocation,
|
||||||
|
SiaPrime: siaPrimeLocation,
|
||||||
},
|
},
|
||||||
PIDS: {
|
PIDS: {
|
||||||
Hyperspace: results.Hyperspace.PID,
|
Hyperspace: results.Hyperspace.PID,
|
||||||
Sia: results.Sia.PID,
|
Sia: results.Sia.PID,
|
||||||
|
SiaPrime: results.SiaPrime.PID,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|||||||
56
src/App.js
56
src/App.js
@@ -80,6 +80,10 @@ class App extends Component {
|
|||||||
AutoMount: false,
|
AutoMount: false,
|
||||||
MountLocation: '',
|
MountLocation: '',
|
||||||
},
|
},
|
||||||
|
SiaPrime: {
|
||||||
|
AutoMount: false,
|
||||||
|
MountLocation: '',
|
||||||
|
},
|
||||||
UpgradeAvailable: false,
|
UpgradeAvailable: false,
|
||||||
UpgradeData: {},
|
UpgradeData: {},
|
||||||
UpgradeDismissed: false,
|
UpgradeDismissed: false,
|
||||||
@@ -168,11 +172,15 @@ class App extends Component {
|
|||||||
...this.state.Sia
|
...this.state.Sia
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let siaPrime = {
|
||||||
|
...this.state.SiaPrime
|
||||||
|
};
|
||||||
|
|
||||||
let hyperspace = {
|
let hyperspace = {
|
||||||
...this.state.Hyperspace
|
...this.state.Hyperspace
|
||||||
};
|
};
|
||||||
|
|
||||||
this.saveState(this.state.Release, this.state.Version, sia, hyperspace);
|
this.saveState(this.state.Release, this.state.Version, sia, hyperspace, siaPrime);
|
||||||
|
|
||||||
if (storageType === 'Hyperspace') {
|
if (storageType === 'Hyperspace') {
|
||||||
hyperspace.AutoMount = e.target.checked;
|
hyperspace.AutoMount = e.target.checked;
|
||||||
@@ -184,6 +192,11 @@ class App extends Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
Sia: sia,
|
Sia: sia,
|
||||||
});
|
});
|
||||||
|
} else if (storageType === 'SiaPrime') {
|
||||||
|
siaPrime.AutoMount = e.target.checked;
|
||||||
|
this.setState({
|
||||||
|
SiaPrime: siaPrime,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -230,8 +243,11 @@ class App extends Component {
|
|||||||
const sia = storageType === 'Sia' ? state : {
|
const sia = storageType === 'Sia' ? state : {
|
||||||
...this.state.Sia,
|
...this.state.Sia,
|
||||||
};
|
};
|
||||||
|
const siaPrime = storageType === 'SiaPrime' ? state : {
|
||||||
|
...this.state.SiaPrime,
|
||||||
|
};
|
||||||
|
|
||||||
this.saveState(this.state.Release, this.state.Version, sia, hyperspace);
|
this.saveState(this.state.Release, this.state.Version, sia, hyperspace, siaPrime);
|
||||||
this.setState({
|
this.setState({
|
||||||
[storageType]: state,
|
[storageType]: state,
|
||||||
});
|
});
|
||||||
@@ -240,7 +256,7 @@ class App extends Component {
|
|||||||
handleReleaseChanged = (e) => {
|
handleReleaseChanged = (e) => {
|
||||||
const val = parseInt(e.target.value, 10);
|
const val = parseInt(e.target.value, 10);
|
||||||
const versionIndex = this.state.VersionLookup[this.state.ReleaseTypes[val]].length - 1;
|
const versionIndex = this.state.VersionLookup[this.state.ReleaseTypes[val]].length - 1;
|
||||||
this.saveState(val, versionIndex, this.state.Sia, this.state.Hyperspace);
|
this.saveState(val, versionIndex, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
|
||||||
this.setState({
|
this.setState({
|
||||||
Release: val,
|
Release: val,
|
||||||
Version: versionIndex
|
Version: versionIndex
|
||||||
@@ -287,7 +303,7 @@ class App extends Component {
|
|||||||
|
|
||||||
handleVersionChanged = (e) => {
|
handleVersionChanged = (e) => {
|
||||||
const val = parseInt(e.target.value, 10);
|
const val = parseInt(e.target.value, 10);
|
||||||
this.saveState(this.state.Release, val, this.state.Sia, this.state.Hyperspace);
|
this.saveState(this.state.Release, val, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
|
||||||
this.setState({
|
this.setState({
|
||||||
Version: val
|
Version: val
|
||||||
}, ()=> {
|
}, ()=> {
|
||||||
@@ -406,16 +422,26 @@ class App extends Component {
|
|||||||
|
|
||||||
onGetStateReply = (event, arg) => {
|
onGetStateReply = (event, arg) => {
|
||||||
if (arg.data) {
|
if (arg.data) {
|
||||||
if (arg.data.Hyperspace.AutoMount === undefined) {
|
let hyperspace = arg.data.Hyperspace || this.state.Hyperspace;
|
||||||
arg.data.Hyperspace['AutoMount'] = false;
|
if (hyperspace.AutoMount === undefined) {
|
||||||
|
hyperspace['AutoMount'] = false;
|
||||||
}
|
}
|
||||||
if (arg.data.Sia.AutoMount === undefined) {
|
|
||||||
arg.data.Sia['AutoMount'] = false;
|
let sia = arg.data.Sia || this.state.Sia;
|
||||||
|
if (sia.AutoMount === undefined) {
|
||||||
|
sia['AutoMount'] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let siaPrime = arg.data.SiaPrime || this.state.SiaPrime;
|
||||||
|
if (siaPrime.AutoMount === undefined) {
|
||||||
|
siaPrime['AutoMount'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
Hyperspace: arg.data.Hyperspace,
|
Hyperspace: hyperspace,
|
||||||
Release: arg.data.Release,
|
Release: arg.data.Release,
|
||||||
Sia: arg.data.Sia,
|
Sia: sia,
|
||||||
|
SiaPrime: siaPrime,
|
||||||
Version: arg.data.Version,
|
Version: arg.data.Version,
|
||||||
}, ()=> {
|
}, ()=> {
|
||||||
this.grabReleases();
|
this.grabReleases();
|
||||||
@@ -431,7 +457,7 @@ class App extends Component {
|
|||||||
let version = this.state.Version;
|
let version = this.state.Version;
|
||||||
if ((version === -1) || !versionLookup[this.state.ReleaseTypes[this.state.Release]][version]) {
|
if ((version === -1) || !versionLookup[this.state.ReleaseTypes[this.state.Release]][version]) {
|
||||||
version = latestVersion;
|
version = latestVersion;
|
||||||
this.saveState(this.state.Release, version, this.state.Sia, this.state.Hyperspace);
|
this.saveState(this.state.Release, version, this.state.Sia, this.state.Hyperspace, this.state.SiaPrime);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -518,7 +544,7 @@ class App extends Component {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
saveState = (release, version, sia, hyperspace)=> {
|
saveState = (release, version, sia, hyperspace, siaPrime)=> {
|
||||||
if (ipcRenderer) {
|
if (ipcRenderer) {
|
||||||
ipcRenderer.send(Constants.IPC_Save_State, {
|
ipcRenderer.send(Constants.IPC_Save_State, {
|
||||||
Directory: Constants.DATA_LOCATIONS[this.props.platform],
|
Directory: Constants.DATA_LOCATIONS[this.props.platform],
|
||||||
@@ -526,6 +552,7 @@ class App extends Component {
|
|||||||
Hyperspace: hyperspace,
|
Hyperspace: hyperspace,
|
||||||
Release: release,
|
Release: release,
|
||||||
Sia: sia,
|
Sia: sia,
|
||||||
|
SiaPrime: siaPrime,
|
||||||
Version: version,
|
Version: version,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -637,7 +664,7 @@ class App extends Component {
|
|||||||
let key = 0;
|
let key = 0;
|
||||||
mainContent.push((
|
mainContent.push((
|
||||||
<div key={'rvd_' + key++}
|
<div key={'rvd_' + key++}
|
||||||
style={{height: '44%'}}>
|
style={{height: '34%'}}>
|
||||||
<ReleaseVersionDisplay disabled={this.state.DownloadActive || this.state.ExtractActive || this.state.MountsBusy}
|
<ReleaseVersionDisplay disabled={this.state.DownloadActive || this.state.ExtractActive || this.state.MountsBusy}
|
||||||
downloadClicked={this.handleReleaseDownload}
|
downloadClicked={this.handleReleaseDownload}
|
||||||
downloadDisabled={!downloadEnabled}
|
downloadDisabled={!downloadEnabled}
|
||||||
@@ -656,7 +683,7 @@ class App extends Component {
|
|||||||
if (allowMount) {
|
if (allowMount) {
|
||||||
mainContent.push((
|
mainContent.push((
|
||||||
<div key={'md_' + key++}
|
<div key={'md_' + key++}
|
||||||
style={{height: '56%'}}>
|
style={{height: '28%'}}>
|
||||||
<MountItems allowConfig={allowConfig}
|
<MountItems allowConfig={allowConfig}
|
||||||
autoMountChanged={this.handleAutoMountChanged}
|
autoMountChanged={this.handleAutoMountChanged}
|
||||||
autoMountProcessed={this.notifyAutoMountProcessed}
|
autoMountProcessed={this.notifyAutoMountProcessed}
|
||||||
@@ -669,6 +696,7 @@ class App extends Component {
|
|||||||
platform={this.props.platform}
|
platform={this.props.platform}
|
||||||
processAutoMount={!this.state.AutoMountProcessed}
|
processAutoMount={!this.state.AutoMountProcessed}
|
||||||
sia={this.state.Sia}
|
sia={this.state.Sia}
|
||||||
|
siaprime={this.state.SiaPrime}
|
||||||
version={this.state.InstalledVersion}/>
|
version={this.state.InstalledVersion}/>
|
||||||
</div>
|
</div>
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -36,6 +36,12 @@ class MountItems extends Component {
|
|||||||
Mounted: false,
|
Mounted: false,
|
||||||
PID: -1,
|
PID: -1,
|
||||||
},
|
},
|
||||||
|
SiaPrime: {
|
||||||
|
AllowMount: false,
|
||||||
|
DriveLetters: [],
|
||||||
|
Mounted: false,
|
||||||
|
PID: -1,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
componentWillUnmount = () => {
|
componentWillUnmount = () => {
|
||||||
@@ -104,6 +110,13 @@ class MountItems extends Component {
|
|||||||
Mounted: (arg.data.Locations.Sia.length > 0),
|
Mounted: (arg.data.Locations.Sia.length > 0),
|
||||||
PID: arg.data.PIDS.Sia,
|
PID: arg.data.PIDS.Sia,
|
||||||
};
|
};
|
||||||
|
const siaPrime = {
|
||||||
|
...this.state.SiaPrime,
|
||||||
|
AllowMount: true,
|
||||||
|
DriveLetters: (arg.data.DriveLetters.SiaPrime),
|
||||||
|
Mounted: (arg.data.Locations.SiaPrime.length > 0),
|
||||||
|
PID: arg.data.PIDS.SiaPrime,
|
||||||
|
};
|
||||||
const hs = {
|
const hs = {
|
||||||
...this.state.Hyperspace,
|
...this.state.Hyperspace,
|
||||||
AllowMount: true,
|
AllowMount: true,
|
||||||
@@ -117,6 +130,7 @@ class MountItems extends Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
Hyperspace: hs,
|
Hyperspace: hs,
|
||||||
Sia: sia,
|
Sia: sia,
|
||||||
|
SiaPrime: siaPrime,
|
||||||
}, () => {
|
}, () => {
|
||||||
let hsLocation = arg.data.Locations.Hyperspace;
|
let hsLocation = arg.data.Locations.Hyperspace;
|
||||||
if ((hsLocation.length === 0) && (this.props.platform === 'win32')) {
|
if ((hsLocation.length === 0) && (this.props.platform === 'win32')) {
|
||||||
@@ -134,6 +148,14 @@ class MountItems extends Component {
|
|||||||
this.props.changed('Sia', siaLocation);
|
this.props.changed('Sia', siaLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let siaPrimeLocation = arg.data.Locations.SiaPrime;
|
||||||
|
if ((siaPrimeLocation.length === 0) && (this.props.platform === 'win32')) {
|
||||||
|
siaPrimeLocation = this.props.siaprime.MountLocation || arg.data.DriveLetters.SiaPrime[0];
|
||||||
|
}
|
||||||
|
if (siaPrimeLocation !== this.props.siaprime.MountLocation) {
|
||||||
|
this.props.changed('SiaPrime', siaPrimeLocation);
|
||||||
|
}
|
||||||
|
|
||||||
this.performAutoMount();
|
this.performAutoMount();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -171,6 +193,11 @@ class MountItems extends Component {
|
|||||||
(this.props.sia.MountLocation.length > 0)) {
|
(this.props.sia.MountLocation.length > 0)) {
|
||||||
this.handleMountUnMount('Sia', true, this.props.sia.MountLocation);
|
this.handleMountUnMount('Sia', true, this.props.sia.MountLocation);
|
||||||
}
|
}
|
||||||
|
if (this.props.siaprime.AutoMount &&
|
||||||
|
!this.state.SiaPrime.Mounted &&
|
||||||
|
(this.props.siaprime.MountLocation.length > 0)) {
|
||||||
|
this.handleMountUnMount('SiaPrime', true, this.props.siaprime.MountLocation);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -204,6 +231,20 @@ class MountItems extends Component {
|
|||||||
pid={this.state.Sia.PID}
|
pid={this.state.Sia.PID}
|
||||||
platform={this.props.platform}
|
platform={this.props.platform}
|
||||||
title={'Sia'}/>
|
title={'Sia'}/>
|
||||||
|
<div style={{paddingTop: '8px'}}/>
|
||||||
|
<MountItem allowConfig={this.props.allowConfig}
|
||||||
|
allowMount={this.state.Sia.AllowMount}
|
||||||
|
autoMount={this.props.siaprime.AutoMount}
|
||||||
|
autoMountChanged={(e)=>this.props.autoMountChanged('SiaPrime', e)}
|
||||||
|
changed={(e) => this.handleMountLocationChanged('SiaPrime', e.target.value)}
|
||||||
|
clicked={this.handleMountUnMount}
|
||||||
|
configClicked={()=>this.props.configClicked('SiaPrime')}
|
||||||
|
items={this.state.SiaPrime.DriveLetters}
|
||||||
|
location={this.props.siaprime.MountLocation}
|
||||||
|
mounted={this.state.SiaPrime.Mounted}
|
||||||
|
pid={this.state.SiaPrime.PID}
|
||||||
|
platform={this.props.platform}
|
||||||
|
title={'SiaPrime'}/>
|
||||||
</div>);
|
</div>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user