Closed Bug 965312 Opened 11 years ago Closed 8 years ago

Evaluate having an option for specifying the cursor direction when retrieving message threads

Categories

(Firefox OS Graveyard :: RIL, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(blocking-b2g:-)

RESOLVED WONTFIX
blocking-b2g -

People

(Reporter: gsvelto, Assigned: gsvelto)

Details

Attachments

(2 files, 1 obsolete file)

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

As discussed in bug 963475 we might want to add an option to specify in which order the threads retrieved via MozMobileMessageManager.getThreads() are returned. We have a similar option for MozMobileMessageManager.getMessages() and it's specified as an optional boolean parameter. As :rwaldron pointed out in bug 963475 comment 13 this is not very readable by someone who's not already familiar with the API. Instead an optional options object (no pun intended) can be passed, e.g.:

* Default order of retrieval

MozMobileMessageManager.getThreads()

or

MozMobileMessageManager.getThreads({ reverse: false })

* Reversed order of retrieval

MozMobileMessageManager.getThreads({ reverse: true })

For both better readability and consistency we might modify MozMobileMessageManager.getMessages's second parameter accordingly.
Assignee: nobody → gsvelto
Attachment #8368082 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Comment on attachment 8373365 [details] [diff] [review]
[PATCH] Add an options object to specify the order of retrieval of messages and threads

This is my proposed change to the MozMobileMessageManager API that uses an options object to pass optional parameters to the getThreads() and getMessages() calls. In this case I've implemented the |reverse| parameter that was already available in getMessages() and I've extended it to cover getThreads() too.

I had only a couple of answers on dev-webapi about this but both seemed positive so I think it should be OK to go ahead with it.

I've also attached a Gaia patch that modifies the SMS app to make use of the new parameters.
Attachment #8373365 - Flags: feedback?(vyang)
This looks really good, thank you for addressing the argument form :)
Comment on attachment 8373365 [details] [diff] [review]
[PATCH] Add an options object to specify the order of retrieval of messages and threads

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

::: dom/mobilemessage/src/MobileMessageManager.cpp
@@ +402,5 @@
>    if (!filter) {
>      filter = new SmsFilter();
>    }
>  
> +  if (aArgc == 1) {

aArgc == 2

::: dom/mobilemessage/tests/marionette/test_getthreads.js
@@ +166,2 @@
>           "' should be found in bodies array.");
> +      messageCount++;

The problem here is, there might be two messages of the same timestamp.  SMS timstamps are of seconds.  It's quite possible that in our testing environment, especially running on your mighty desktop beast, to have two messages of identical timestamp.  For these messages, their order in the output of |getMessages| is undefined, and therefore we cannot assume an absolutely increasing order here.
Attachment #8373365 - Flags: feedback?(vyang) → superreview+
(In reply to Vicamo Yang [:vicamo][:vyang] from comment #6)
> ::: dom/mobilemessage/src/MobileMessageManager.cpp
> @@ +402,5 @@
> >    if (!filter) {
> >      filter = new SmsFilter();
> >    }
> >  
> > +  if (aArgc == 1) {
> 
> aArgc == 2

Strangely enough that doesn't seem to work. It seems that aArgc == 0 if I pass only one argument and aArgc == 1 if I pass two. Is it possible it's counting only the optional arguments and not the required ones?

> ::: dom/mobilemessage/tests/marionette/test_getthreads.js
> @@ +166,2 @@
> >           "' should be found in bodies array.");
> > +      messageCount++;
> 
> The problem here is, there might be two messages of the same timestamp.  SMS
> timstamps are of seconds.  It's quite possible that in our testing
> environment, especially running on your mighty desktop beast, to have two
> messages of identical timestamp.  For these messages, their order in the
> output of |getMessages| is undefined, and therefore we cannot assume an
> absolutely increasing order here.

I'm not exactly sure how this affects that particular bit of code; the tests seem to pass on my machine though. Do you mean this might introduce intermittent issues if we end up with two messages with the same timestamp?
blocking-b2g: --- → backlog
blocking-b2g: backlog → -
We will most likely remove this API.
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: