CouchChat-iOS demo: archiving messages

29 views
Skip to first unread message

Guofeng Zhang

unread,
Oct 27, 2014, 9:57:12 PM10/27/14
to mobile-c...@googlegroups.com
Similar to this demo, my app have a long live chat room, but I only want the part of the messages for this room be synced to devices. I can do it by defining the syn function to only sync the messages before some day, for example, only the messages in last 30 days could be synced to the devices.

But there is a problem to view the other messages that not synced to devices. for example using pull-to-refresh to view the old messages. What I could consider is to use our own app server to fetch these old messages page by page.

But this has another problem, that is, to display the messages, I have to code two part logic: some uses the synced docs, others uses remote HTTP access to our own app server.  This will make the app complicated. so I might use our own app server to server all the messages, and this make the sync gateway not used.

So my question is:
     Any better way for this case, that is, support the archiving message and at the same time could browse it?

This let me ask a general question, what pattern which the sync gateway is appropriate to be used?

Thanks for you help.

Guofeng

Jens Alfke

unread,
Oct 27, 2014, 11:00:23 PM10/27/14
to mobile-c...@googlegroups.com
On Oct 27, 2014, at 6:57 PM, Guofeng Zhang <guof...@gmail.com> wrote:

Similar to this demo, my app have a long live chat room, but I only want the part of the messages for this room be synced to devices. I can do it by defining the syn function to only sync the messages before some day, for example, only the messages in last 30 days could be synced to the devices.

That won't work. The sync function sees a document only when the doc is updated. If the doc isn't updated for 30 days, it's no longer 'current' but the channels it's in won't change.

What you can do is to assign channels on something like a monthly basis — for example channels named 2014_07, 2014_08, 2014_09… Then you assign a doc to the channel based on the year/month it was last updated. The clients can now sync with the latest one or two months' channels to get only the recent documents.

But there is a problem to view the other messages that not synced to devices. for example using pull-to-refresh to view the old messages. What I could consider is to use our own app server to fetch these old messages page by page.

I just posted about that this morning; hopefully that message will be useful.

—Jens

Guofeng Zhang

unread,
Oct 30, 2014, 11:50:27 PM10/30/14
to mobile-c...@googlegroups.com
Thanks for the detailed reply.

Is it a good idea to use "purging a document" to implement dismiss messages? that is, make the document not appearing on one device but the other devices can still see this message normally.



--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/B604AF27-9737-4232-B080-338A3C8DC39E%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages