SiaPrime support
This commit is contained in:
32
electron.js
32
electron.js
@@ -21,7 +21,7 @@ let mountedPIDs = [];
|
||||
|
||||
function createWindow() {
|
||||
// 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({
|
||||
width: 425,
|
||||
height: height,
|
||||
@@ -191,16 +191,18 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
||||
let driveLetters = {
|
||||
Hyperspace: [],
|
||||
Sia: [],
|
||||
SiaPrime: [],
|
||||
};
|
||||
|
||||
const grabDriveLetters = (hsLocation, siaLocation) => {
|
||||
const grabDriveLetters = (hsLocation, siaLocation, siaPrimeLocation) => {
|
||||
for (let i = 'c'.charCodeAt(0); i <= 'z'.charCodeAt(0); i++) {
|
||||
const drive = (String.fromCharCode(i) + ':').toUpperCase();
|
||||
if (!(hsLocation.startsWith(drive) || siaLocation.startsWith(drive))) {
|
||||
if (!(hsLocation.startsWith(drive) || siaLocation.startsWith(drive) || siaPrimeLocation.startsWith(drive))) {
|
||||
try {
|
||||
if (!fs.existsSync(drive)) {
|
||||
driveLetters.Hyperspace.push(drive);
|
||||
driveLetters.Sia.push(drive);
|
||||
driveLetters.SiaPrime.push(drive);
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
@@ -222,17 +224,21 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
||||
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') {
|
||||
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'));
|
||||
} 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 {
|
||||
image = nativeImage.createFromPath(path.join(__dirname, '/build/logo.png'));
|
||||
}
|
||||
@@ -247,21 +253,25 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
||||
.then((results) => {
|
||||
let hsLocation = results.Hyperspace.Location;
|
||||
let siaLocation = results.Sia.Location;
|
||||
let siaPrimeLocation = results.SiaPrime.Location;
|
||||
if (os.platform() === 'win32') {
|
||||
hsLocation = hsLocation.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, {
|
||||
DriveLetters: driveLetters,
|
||||
Locations: {
|
||||
Hyperspace: hsLocation,
|
||||
Sia: siaLocation,
|
||||
SiaPrime: siaPrimeLocation,
|
||||
},
|
||||
PIDS: {
|
||||
Hyperspace: results.Hyperspace.PID,
|
||||
Sia: results.Sia.PID,
|
||||
SiaPrime: results.SiaPrime.PID,
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user