Lepton icon indicating copy to clipboard operation
Lepton copied to clipboard

Local DB support

Open darkworks opened this issue 7 years ago • 16 comments
trafficstars

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 avatar Feb 10 '18 14:02 darkworks

@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:)

hackjutsu avatar Feb 15 '18 04:02 hackjutsu

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 avatar Apr 05 '18 09:04 Mesod

@Mesod

Thanks for taking this initiative! Lepton uses Redux to maintain its states. The most intuitive implementation for a local database integration is

  1. Persist its redux state to a database before the close.
  2. 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.

hackjutsu avatar Apr 06 '18 05:04 hackjutsu

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 avatar Apr 07 '18 09:04 Mesod

@Mesod using something like https://github.com/rt2zz/redux-persist with https://github.com/psperber/redux-persist-electron-storage should help a lot.

rawrmonstar avatar Apr 24 '18 02:04 rawrmonstar

Hello everyone, this feature is a must imo ! How is it progressing ?

ghost avatar Aug 13 '18 04:08 ghost

no update from mesod , i guess i will have to start work on this feature

darkworks avatar Sep 03 '18 07:09 darkworks

Do you mind if I use localStorage?

maxjing avatar Oct 17 '18 02:10 maxjing

@maxjing Simply send a WIP PR and we can have a discussion there:) Thanks for contribution:)

hackjutsu avatar Oct 17 '18 03:10 hackjutsu

It would be great to have support for local db or other local git backends

gerroon avatar Jan 23 '19 16:01 gerroon

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?

sujin2f avatar Mar 25 '19 15:03 sujin2f

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

darkworks avatar Mar 25 '19 18:03 darkworks

@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 avatar Mar 29 '19 02:03 hackjutsu

@hackjutsu OK. I will make this feature~

schoidev avatar Mar 29 '19 20:03 schoidev

Hey is there any update on this so far?

oskarsh avatar Apr 07 '20 11:04 oskarsh

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.

kasajian avatar Oct 23 '20 06:10 kasajian