Created
March 2, 2017 09:27
-
-
Save shibacomputer/b36e3f6348e6fe03695b9aa3123bd186 to your computer and use it in GitHub Desktop.
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
const remote = window.require('electron').remote | |
const settings = remote.require('electron-settings') | |
module.exports = createModel | |
function createModel() { | |
return { | |
namespace: 'global', | |
effects: { | |
openDatabase: openDatabase | |
}, | |
state: { | |
firstRun: true, | |
databasePath: null, | |
}, | |
reducers: { | |
setDatabasePath: setDatabasePath | |
} | |
} | |
} | |
function setDatabasePath (state, data, send, done) { | |
var newPath = data | |
settings.set('hasDbLocationOf', newPath).then(() => { | |
settings.set('isActiveInstall', true).then(() => { | |
console.log('hello') | |
}) | |
}) | |
} | |
// setup.js | |
// Present the window | |
function setupWindow(state, prev, send) { | |
document.title = 'Welcome to Txt' | |
var txtPath = app.getPath('home') + '/Txt' | |
function pickDirectory(send, done) { | |
dialog.showOpenDialog({ | |
title: 'Choose Your Txt Location', | |
desiredPath: txtPath, | |
properties: [ 'openDirectory', 'createDirectory', 'promptToCreate'] | |
}, function(filePaths) { | |
if (filePaths) txtPath = filePaths[0] | |
send('global:setDatabasePath', txtPath, done) | |
}) | |
} | |
return html` | |
<section class="c ${location}"> | |
<label for="location">Location</label> | |
<div class="container"> | |
<div class="location-input input" onclick=${pickDirectory}> | |
${state.txtPath} | |
</div> | |
<button class="button bg-c" onclick=${pickDirectory}>Change</button> | |
</div> | |
<p class="small w">Txt uses a folder on your computer to save and encrypt your work.</p> | |
</section> | |
` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment