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

Syncs notes when a note is saved or edited. #216

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

deannah
Copy link

@deannah deannah commented Oct 22, 2013

fixes #200

@Stebalien
Copy link
Member

Instead of overriding those functions, you should be able to listen to "add" signals emitted by L.notebook.get("notes").

Also, while this is a stop-gap solution, it's really inefficient. A full sync (what you are doing here) first downloads all of the notes and then pushes the changed notes to the server. Instead, you should only push updated notes. You could do this by calling L.server.pushNotes(). However, if you do this, you will have to handle note conflicts.

Currently, L.server.commitNotes() only reports errors on the console, it doesn't return an error status if a note fails to push because (a) this can only happen if some other instance updated the note on the server since this instance last pulled the note and (b) it'll just get around to syncing that note on the next sync.

Instance A Instance B
pull notes -> [a, b, c, d]
pull notes -> [a, b, c, d]
push notes (update notes a, c, d) -> {a: success, c: success, d: success}
push notes (update note b, c) -> {b: success, c: failure}
.... next sync ....
pull notes -> [a, b, c', d]
push notes -> {c: success}

So you should probably modify commitNotes to return some "temporary failure" status to pushNotes (which can in turn call the error callback). You can then handle this transient error by triggering a full sync.

@Stebalien Stebalien changed the title [Web] Syncs notes when a note is saved or edited. Syncs notes when a note is saved or edited. Feb 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Push note changes made in the webapp to the server immediately
2 participants