Lepton
Lepton copied to clipboard
Local DB support
Environment info
- OS: Windows 7
- App Version (
Command/Ctrl + ,): Latest version
Description of the problem / feature request / question:
i created gist in lepton and it give me error gist creation failed because network was done
the gist was completely lost so i think it will be good in case of network down when gist creation is failed , it should save locally gist and when network is ok on sync it should create locally saved gists on github . Also it will be good if it maintain one local db for gists ,
@darkworks
Thanks for your suggestion! Adding a local DB support is a good idea. Feel free to play with the code and send a PR if the result turns out to be promising:)
I really like to take this challenge and add this new feature to it. But just need some hints, I was thinking that the most logical way is to use sqlite, but seems like its setup and configuration is a pain which is not worthy in our case. I even think that a noSql database could be a really good option or even saving gists in a document may even work(but handling it could become a pain)
@Mesod
Thanks for taking this initiative! Lepton uses Redux to maintain its states. The most intuitive implementation for a local database integration is
- Persist its redux state to a database before the close.
- Retrieve the previous states from the database and feed them to Redux when launch.
You can put some loggings around the following code to get a feel for how these states look like.
https://github.com/hackjutsu/Lepton/blob/84ff4941321599b99eeca193b173b2d3aaa243f7/app/index.js#L350-L351
I would like to address this issue in these phases.
Phase 1
- Instead of using a database, try persisting the states into a JSON file.
- Lepton should be able to restore its previous states from this JSON file if offline.
- When offline, Lepton is read-only.
Phase 2
- Trying replacing the JSON file with a database. (We can have more discussion on the database types when the concept has been proved in phase 1.)
Phase 3
- When offline, try creating and saving snippets into the database. All these snippets are considered as drafts. We need some UI change to display these "draft" snippets.
- When online, Lepton should remind users of these drafts. Users should able to sync them to GitHub service.
Let me know if you have more concrete questions about the code.
Thanks for your help. I will start the phase one ASAP and send a PR once it's done. If I get any problem, I will ask it here.
@Mesod using something like https://github.com/rt2zz/redux-persist with https://github.com/psperber/redux-persist-electron-storage should help a lot.
Hello everyone, this feature is a must imo ! How is it progressing ?
no update from mesod , i guess i will have to start work on this feature
Do you mind if I use localStorage?
@maxjing Simply send a WIP PR and we can have a discussion there:) Thanks for contribution:)
It would be great to have support for local db or other local git backends
Hey guys! If you used the persist store or the db, you also could make 'hide' feature, so users can isolate their snippets and the code chunk for embed.
I was just started make a simple app like this with Electron and found this repo. Can I contribute here?
Hey guys! If you used the persist store or the db, you also could make 'hide' feature, so users can isolate their snippets and the code chunk for embed.
I was just started make a simple app like this with Electron and found this repo. Can I contribute here?
ya sure please contribute this feature is most wanted feature , github is now under Microsoft umbrella , so if they try to messup github then our gits will be locally safe in database
@sujin2f Feel free to contribute to Lepton! We might have to think about the strategy to resolve conflicts between local state and online state once a local DB is integrated.
@hackjutsu OK. I will make this feature~
Hey is there any update on this so far?
Is there any reason why the gists are not stored locally in github repositories? one should be able to update the gist in any repository and then sync it. Lepton can access the local git repositories of the gists, so it works no matter if the user is connected to the internet.