Open deannah opened 10 years ago
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.
fixes #200