Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple-instance support: open multiple instance, one instance update can directly reflect on another instance #686

Open
evan0greenup opened this issue Aug 5, 2024 · 4 comments

Comments

@evan0greenup
Copy link

Currently, only single instance can be opened.

It would be nice to make notes support multiple instance toward single database be opened simultaneously, because user may edit different pages within a single database.

And the content change in one instance can immediately take effect on another instance.

implementation

avoid data corruption:

  • Use transaction feature of underlying database (SQLite).
  • Use filelock (OS-level)

Aware the content update when other instance make change:

  • save the last update timestamp in a file. If the time is newer than the in-memory record, synchronize the content.
  • use file-watcher to keep track of file update.
@zjeffer
Copy link
Collaborator

zjeffer commented Aug 5, 2024

Instead of supporting multiple instances, I think it's better if we support one instance with multiple windows. It would accomplish what you propose without having to implement transactions/filelocks/synchronizations, as we would still handle the database through a single instance.

@nuttyartist
Copy link
Owner

What are you trying to accomplish, @evan0greenup? Editing the same note from multiple windows? If so, how about a split screen feature? Or tabs? Both features I've had on my mind.

@evan0greenup
Copy link
Author

@zjeffer ,@nuttyartist , Here I explain the reasons why I make this proposal:

Previously, I make proposal on launch note with custom profile directory. #682. If launching the notes with different profile/database, It is supposed to run a different instance.

Comparison on two approach

The first one is what @nuttyartist and @zjeffer recommended. Attaching to existed instance with same profile/database. (This is also how firefox works). But it require programming with dbus, and the inter-process communication is quite complicated. At least, I have no clear idea on how to implement it. (May be because I am not experienced enough).

The second one is my proposal. Despite of whether there is existed instance running for given profile directory/database filename. Just to ensure in low level multiple instance toward single database will not cause corruption. This approach is straight-forward.

Cross-platform is a big factor for choosing one among these two approaches above.

@zjeffer
Copy link
Collaborator

zjeffer commented Aug 8, 2024

The first one is what @nuttyartist and @zjeffer recommended. Attaching to existed instance with same profile/database. (This is also how firefox works). But it require programming with dbus, and the inter-process communication is quite complicated. At least, I have no clear idea on how to implement it. (May be because I am not experienced enough).

If you only need to accomplish editing multiple notes from the same database, you could add a way to open a note in a separate window (e.g. by double-clicking or with an option in the context menu), which would still be in the same process (so no IPC necessary).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants