Skip to content

Commit 45a46cb

Browse files
committed
make configurable --disable-direct-write flag
1 parent 567f453 commit 45a46cb

4 files changed

Lines changed: 36 additions & 11 deletions

File tree

browser/main/modal/Preference/AppSettingTab.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ export default class AppSettingTab extends React.Component {
7878
}
7979
}
8080

81+
handleDisableDirectWriteClick (e) {
82+
let config = this.state.config
83+
config['disable-direct-write'] = !config['disable-direct-write']
84+
this.setState({
85+
config
86+
})
87+
}
88+
8189
handleNameSaveButtonClick (e) {
8290
let { dispatch } = this.props
8391

@@ -156,9 +164,8 @@ export default class AppSettingTab extends React.Component {
156164
{
157165
true// !OSX
158166
? (
159-
<div className='sectionInput'>
160-
<label>Direct write(Windows only)</label>
161-
<input disabled={OSX} onKeyDown={e => this.handleConfigKeyDown(e)} type='checkbox'/>
167+
<div className='sectionCheck'>
168+
<label><input onClick={e => this.handleDisableDirectWriteClick(e)} checked={this.state.config['disable-direct-write']} disabled={OSX} type='checkbox'/>Disable Direct Write<span className='sectionCheck-warn'>It will be applied after restarting</span></label>
162169
</div>
163170
)
164171
: null

browser/styles/main/modal/Preferences.styl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ iptFocusBorderColor = #369DCD
6969
font-size 18px
7070
margin 10px 0 5px
7171
color brandColor
72+
&>.sectionCheck
73+
margin-bottom 5px
74+
height 33px
75+
label
76+
width 150px
77+
padding-left 15px
78+
line-height 33px
79+
.sectionCheck-warn
80+
font-size 12px
81+
margin-left 10px
82+
border-left 2px solid brandColor
83+
padding-left 5px
7284
&>.sectionInput
7385
margin-bottom 5px
7486
clearfix()

lib/config.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const electron = require('electron')
22
const app = electron.app
33
const ipc = electron.ipcMain
44
const jetpack = require('fs-jetpack')
5-
const mainWindow = require('./main-window')
65

76
const defaultConfig = {
87
'editor-font-size': '14',
@@ -41,13 +40,20 @@ function saveConfig () {
4140
// Init
4241
global.config = Object.assign({}, defaultConfig, getConfig())
4342

44-
function applyConfig () {
45-
mainWindow.webContents.send('config-apply')
43+
if (global.config['disable-direct-write']) {
44+
app.commandLine.appendSwitch('disable-direct-write')
4645
}
4746

48-
ipc.on('configUpdated', function (event, newConfig) {
49-
global.config = Object.assign({}, defaultConfig, global.config, newConfig)
50-
saveConfig()
51-
applyConfig()
47+
app.on('ready', function () {
48+
const mainWindow = require('./main-window')
49+
function applyConfig () {
50+
mainWindow.webContents.send('config-apply')
51+
}
52+
53+
ipc.on('configUpdated', function (event, newConfig) {
54+
global.config = Object.assign({}, defaultConfig, global.config, newConfig)
55+
saveConfig()
56+
applyConfig()
57+
})
5258
})
5359

lib/main-app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const nodeIpc = require('@rokt33r/node-ipc')
1010
const GhReleases = require('electron-gh-releases')
1111
// electron.crashReporter.start()
1212

13+
require('./config')
1314
var mainWindow = null
1415
var finderProcess = null
1516
var finderWindow = null
@@ -295,7 +296,6 @@ app.on('ready', function () {
295296
})
296297

297298
require('./hotkey')
298-
require('./config')
299299
})
300300

301301
module.exports = app

0 commit comments

Comments
 (0)