Closed Bug 908657 Opened 11 years ago Closed 11 years ago

[Messages] the "unread" bit is not always removed when we read a thread

Categories

(Firefox OS Graveyard :: Gaia::SMS, defect, P1)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: julienw, Assigned: julienw)

References

Details

(Whiteboard: [comms-triaged][u=commsapps-user c=messaging p=1 s=v1.2-features-sprint-4])

Attachments

(1 file, 1 obsolete file)

+++ This bug was initially created as a clone of Bug #907562 +++

STR:
* receive a SMS while you're not in the thread for this sender. For example you can send a sms to yourself, and quickly go to the thread list view while the message is sending
* tap on the thread to go to the thread
* immediately tap the left arrow to go back to the thread list
=> the unread mark has been removed
(you can wait a long time now if you want, this is not time-related here)
* kill the app
* restart the app
=> the unread mark is back

If you wait before tapping the left arrow, the unread mark is really applied.

The problem happens because we ask to mark the messages as read only when the all the messages in the thread have been displayed. So the bug will happen more for big threads.

Therefore I'm asking leo because I think this has a quite important issue for our users (but I'd be ok by putting this in koi... but we need it in koi for sure).
There are several possible fixes here.

1. we mark as read asap when we load the thread. But that means we'd have 2 "getMessages" call in parallel (for marking as read, we use a special filter to get only the unread messages). So this could be problematic.

2. we extend the getMessages option object to have 2 end callbacks: renderEnd, done. Currently, we only have a "end" callback that gets called only when the whole thread has rendered.

But I also think it could be a good idea to have an API to "mark as read" a whole thread, because that's actually the operation we want to do. We never need to "mark as read" an individual message. If we'd have this API we could call it asap without a problem. So NI Gene to have his advice on this.
Flags: needinfo?(gene.lian)
(In reply to Julien Wajsberg [:julienw] from comment #1)
> 1. we mark as read asap when we load the thread. But that means we'd have 2
> "getMessages" call in parallel (for marking as read, we use a special filter
> to get only the unread messages). So this could be problematic.
> 
> But I also think it could be a good idea to have an API to "mark as read" a
> whole thread, because that's actually the operation we want to do. We never
> need to "mark as read" an individual message. If we'd have this API we could
> call it asap without a problem. So NI Gene to have his advice on this.

Have markMessageRead() accept a SmsFilter, then you don't bother getMessages() again.
Yep, works for me too :)
Depends on: 908743
If we let markMessageRead(...) accepts a SmsFilter do this, you can imagine what's going to happen when the user wants to enter a thread. We have to call the following 2 functions separately:

  - getMessages({filterId: xxx})
  - markMessageRead({filterId: xxx})

The backend of these 2 functions actually do lots of similar things for filtering. Calling them separately still sounds redundant to me. However, it still works for me because I don't like to add a flag or callback for getMessages(...), though. Specifically, the |renderEnd| callback sounds more like a UI concept and the Gecko shouldn't be aware of that.

-----
Anyway, back to comment #0, 

> * immediately tap the left arrow to go back to the thread list
> => the unread mark has been removed

I believe this remove is done by Gaia. However, why do we want to do this? If the thread doesn't completely *display* all the messages, marking the thread as unread still makes sense to me because I didn't actually see/read those messages yet by my eyes! Entering and out the thread quickly doesn't imply I've already read all the messages.

Personally, this bug sounds a no-issue to me. Well, not an leo+ at least. What do you guys think?
Flags: needinfo?(gene.lian)
Gene, the "renderEnd" part was really for Gaia, not for Gecko, so don't worry :)

About the bug: when a user reads the thread, the unread part is likely the latest messages, that are displayed at the very start.

Another fix comes to my mind: while rendering, we could mark "read" only those messages that we rendered and were unread. We would still need the "renderEnd" part (still in Gaia :) ) to know when to do the "mark as read" operation. That sounds more sensible because we would actually mark "read" only those messages that were actually displayed. Of course, this could mark "read" messages that are displayed not currently visible (because above the top), but this is imho not a big problem.
Depends on: 907562
(In reply to Julien Wajsberg [:julienw] from comment #5)
> Gene, the "renderEnd" part was really for Gaia, not for Gecko, so don't
> worry :)

Don't quite know what the effort to implement "renderEnd"?  Do you need an extra event or something else for it?
One interesting to notice: the formal W3 API is proposing a markConversationRead() function, which takes conversationID as the parameter (equivalent to our threadID). Maybe, we should make it that way instead of adding a big filter into markMessageRead especially we always use the filter to input threadID only.

[1] http://messaging.sysapps.org/#widl-MessagingManager-markConversationRead-Promise-DOMString-conversationID-boolean-value
Vicamo> nope, it's purely a gaia thing. Basically, we end our rendering loop at one point, and the result is that we don't call the "end" function in that case. This is a small effort, I just need a few hours to get this ready.
No longer depends on: 908743
Adding qawanted to see how easily and often this is reproducible and also compare the behavior with 1.0.1 before blocking here.
Keywords: qawanted
QA Contact: sparsons
QA Contact: sparsons → sarsenyev
QA Contact: sarsenyev
QA Contact: sparsons
I was able to reproduce this issue very easily 3/5 attempts on both Leo 1.1 Comm and Unagi 1.0.1 

Unagi 1.0.1

Build ID: 20130828043201
Gecko: http://hg.mozilla.org/releases/mozilla-b2g18_v1_0_1/rev/9c62297d11b0
Gaia: 054cdc27404e2daca91d3065d9783681032b2151
Platform Version: 18.0

Leo 1.1

Build ID: 20130828041203
Gecko: http://hg.mozilla.org/releases/mozilla-b2g18/rev/c3b4683d1360
Gaia: 518178ca234c98eb1ca0c0997b9d59faea640a85
Platform Version: 18.1
RIL Version: 01.01.00.019.205 

The "unread" icon reappears after user opens SMS thread, immediately selects "back" to go back to the main SMS screen, kills app process, then reopens SMS app.
Keywords: qawanted
Minus since it is common to both 1.1 and 1.0.1.
blocking-b2g: leo? → -
blocking-b2g: - → koi?
when this is landed in master please re-nominate
blocking-b2g: koi? → ---
Whiteboard: [comms-triaged]
When 912943 will be done I think we'll still want to implement a "renderEnd" property in Gaia Messages App' MessageManager (_not_ in the Mobile Message API), because writing to the db while we're reading it seems a bad idea performance-wise.

So I think we can implement this in this bug, and change the current markMessagesRead implementation to use bug 912943 in another bug. What do you think Gene ?
(In reply to Julien Wajsberg [:julienw] from comment #13)
> When 912943 will be done I think we'll still want to implement a "renderEnd"
> property in Gaia Messages App' MessageManager (_not_ in the Mobile Message
> API), because writing to the db while we're reading it seems a bad idea
> performance-wise.

Don't really get it at comment #5 but I'm totally fine with that since it's not related to the Gecko change. :)

> So I think we can implement this in this bug, and change the current
> markMessagesRead implementation to use bug 912943 in another bug. What do
> you think Gene ?

Sounds good to me. So, adding the 'renderEnd' in the Gaia can solve this issue independently? Or the Gaia still needs the support of markConversationRead()?
This will solve it independently.
OK, I removed the dependency of bug 912943 and let's do the fix with 'renderEnd' in this bug. Thanks!
No longer depends on: 912943
Assignee: nobody → felash
Whiteboard: [comms-triaged] → [comms-triaged][u=commsapps-user c=messaging p=1 s=v1.2-features-sprint-4]
Attached patch patch v1 (obsolete) (deleted) — Splinter Review
Github pull request is https://github.com/mozilla-b2g/gaia/pull/11964

* added a markThreadRead in MessageManager, make the code easier to read and it
  will make it easier to use the new method from Bug 912943.
* added a "done" callback that is always called by getMessages
* we always mark the messages as read so removed unnecessary arguments to this
  method
* made renderMessages take a threadId instead of a filter, this was a leftover
  of our conversion to threadId instead of phone numbers
---
 apps/sms/js/message_manager.js              |   48 ++++++++----
 apps/sms/js/thread_ui.js                    |   76 +++++++++----------
 apps/sms/test/unit/message_manager_test.js  |  107 ++++++++++++++++++++++++++-
 apps/sms/test/unit/mock_message_manager.js  |    4 +-
 apps/sms/test/unit/mock_moz_sms_filter.js   |    1 +
 apps/sms/test/unit/mock_navigatormoz_sms.js |   47 ++++++++++++
 apps/sms/test/unit/thread_ui_test.js        |   17 +++++
 7 files changed, 244 insertions(+), 56 deletions(-)
 create mode 100644 apps/sms/test/unit/mock_moz_sms_filter.js
Attachment #800286 - Flags: review?(fbsc)
Comment on attachment 800286 [details] [diff] [review]
patch v1

Review of attachment 800286 [details] [diff] [review]:
-----------------------------------------------------------------

Great work. No comments to add! R+ for sure :). Gracias!
Attachment #800286 - Flags: review?(fbsc) → review+
Attached patch patch v2 (deleted) — Splinter Review
So, this was failing a unit test (in the old sms_test.js test file), so I modified this and will see how it looks like in Travis.

carrying r=borja for this
Attachment #800286 - Attachment is obsolete: true
Attachment #803566 - Flags: review+
It's green !

master: 503d9f1847032ca0c62a80c930d749c4e19397b3
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: