couchbaselabs / ToDoLite-iOS

To-Do list sample app for Couchbase Lite, native iOS version
85 stars 41 forks source link

Indicate when lists / items haven't been pushed up to sync gateway yet #63

Open tleyden opened 8 years ago

tleyden commented 8 years ago

Indicate todo lists and todo items that have not been pushed up to Sync Gw yet by changing the font to light grey (as is done in the Evernote app)

jamesnocentini commented 8 years ago

Do you think this could be done with the new pendingDocuments method in 1.2? It'd then be possible to show a notification badge with the number of docs that have not been pushed. Maybe the replication event can also be used to trigger the different title color when it's pushed.

tleyden commented 8 years ago

There's also an isDocumentPending method.

REF: https://github.com/couchbase/couchbase-lite-ios/issues/442

snej commented 8 years ago

Yes, this is exactly what that 1.2 feature is for.

tleyden commented 8 years ago

@pasin / @PaulCapestany what about this approach?

We assume that the item will sync, and the first 5 seconds after an item was created we just show it as black no matter what the state of repl.isDocumentPending(task). After 5 seconds, we will check the repl.isDocumentPending(task) state, and if it's still pending, we'll show it as grey. But rather than using a timer, we just compare the timestamps. So the code becomes:

# showing a table cell
delta = time.Now() - task.CreatedAt()
if delta < 5.seconds:
   textColor = black
else
   textColor = repl.isDocumentPending(task)

The user experience will be very similar to the current user experience on the master branch, in that any items added will immediately appear as black (and no flickering), but if the item hasn't sync'd for 5 seconds, they will flip to grey to alert the user that something might be wrong with the replication (very useful for QE testing)

pasin commented 8 years ago

@tleyden, I think we still need a kind of timer (timer, kvo, or prrform with delay) to keep checkingtbe status after 5 secs. I plan to take the current PR and feel the flickering first.

tleyden commented 8 years ago

It doesn't have to turn to grey (if it doesn't sync) exactly 5 seconds later, as long as that table cell callback gets called at some point, then it would turn to grey.

I plan to take the current PR and feel the flickering first.

ok sounds good. Btw, expect buggy behavior until https://github.com/couchbase/couchbase-lite-ios/issues/1132 is resolved.