-
Notifications
You must be signed in to change notification settings - Fork 875
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #564 from ipfs-shipyard/user-options
User options and auto launch
- Loading branch information
Showing
22 changed files
with
453 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const AutoLaunch = require('auto-launch') | ||
|
||
const settingsOption = 'autoLaunch' | ||
const autoLauncher = new AutoLaunch({ | ||
name: 'IPFS Station' | ||
}) | ||
|
||
export default function (opts) { | ||
let {logger, settingsStore} = opts | ||
|
||
let activate = (value) => { | ||
if (value === true) { | ||
autoLauncher.enable().catch(logger.error) | ||
} else { | ||
autoLauncher.disable().catch(logger.error) | ||
} | ||
} | ||
|
||
activate(settingsStore.get(settingsOption)) | ||
settingsStore.on(settingsOption, activate) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import {join} from 'path' | ||
import {shell, ipcMain, BrowserWindow} from 'electron' | ||
|
||
function setupWindow (opts) { | ||
const options = opts.settingsWindow | ||
const window = new BrowserWindow(options) | ||
|
||
window.setMenu(null) | ||
window.loadURL(options.index) | ||
window.on('close', (event) => { | ||
event.preventDefault() | ||
window.hide() | ||
}) | ||
|
||
// Replace the window settings by the actual | ||
// instance of BrowserWindow | ||
opts.settingsWindow = window | ||
} | ||
|
||
function open (opts) { | ||
const {settingsWindow, settingsStore} = opts | ||
|
||
return () => { | ||
settingsWindow.webContents.send('settings', settingsStore.toObject()) | ||
settingsWindow.show() | ||
settingsWindow.focus() | ||
} | ||
} | ||
|
||
function openNodeConfig (opts) { | ||
const {settingsStore} = opts | ||
|
||
return () => { | ||
const path = settingsStore.get('ipfsPath') | ||
shell.openExternal(join(path, 'config')) | ||
} | ||
} | ||
|
||
function updateSettings (opts) { | ||
const {settingsStore} = opts | ||
|
||
return (event, settings) => { | ||
for (const key in settings) { | ||
if (settings.hasOwnProperty(key)) { | ||
settingsStore.set(key, settings[key]) | ||
} | ||
} | ||
} | ||
} | ||
|
||
export default function (opts) { | ||
setupWindow(opts) | ||
|
||
ipcMain.on('open-settings', open(opts)) | ||
ipcMain.on('update-settings', updateSettings(opts)) | ||
ipcMain.on('open-node-settings', openNodeConfig(opts)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.