generated from sindresorhus/electron-boilerplate
-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c0bec3
commit 9473597
Showing
9 changed files
with
136 additions
and
18 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
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,72 @@ | ||
const electron = require( 'electron' ) | ||
const actions = require( './actions' ) | ||
const log = require( './log' ) | ||
const electronPreferences = require( './electron-preferences' ) | ||
const sound = require( './sound' ) | ||
const windows = require( './windows' ) | ||
|
||
const app = skipFullReset => { | ||
|
||
sound.play( 'RESET' ) | ||
|
||
// Close extra crosshairs | ||
windows.closeAllShadows() | ||
|
||
// Hides chooser and preferences | ||
actions.escape() | ||
|
||
windows.center() | ||
reset.preferences() | ||
|
||
if ( !skipFullReset ) { | ||
|
||
// todo - circular dependency using: | ||
// init() | ||
// Using app.relaunch to cheat | ||
|
||
// or, to restart completely | ||
electron.app.relaunch() | ||
electron.app.exit() | ||
|
||
} | ||
|
||
} | ||
|
||
const preference = key => { | ||
|
||
try { | ||
|
||
const [ groupId, id ] = key.split( '.' ) | ||
const group = electronPreferences.defaults[groupId] | ||
const defaultValue = group[id] | ||
|
||
log.info( `Setting default value ${defaultValue} for ${key}` ) | ||
electronPreferences.value( key, defaultValue ) | ||
|
||
} catch ( error ) { | ||
|
||
log.warn( error ) | ||
|
||
} | ||
|
||
} | ||
|
||
// Temp until implemented in electron-preferences | ||
const preferences = () => { | ||
|
||
const { defaults } = electronPreferences | ||
for ( const [ key, value ] of Object.entries( defaults ) ) { | ||
|
||
electronPreferences.value( key, value ) | ||
|
||
} | ||
|
||
} | ||
|
||
const reset = { | ||
app, | ||
preference, | ||
preferences, | ||
} | ||
|
||
module.exports = reset |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.