Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shibacomputer/b36e3f6348e6fe03695b9aa3123bd186 to your computer and use it in GitHub Desktop.
Save shibacomputer/b36e3f6348e6fe03695b9aa3123bd186 to your computer and use it in GitHub Desktop.
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