Closed
Bug 963475
Opened 11 years ago
Closed 11 years ago
Provide a way to fetch the message threads in reverse order
Categories
(Firefox OS Graveyard :: RIL, defect, P1)
Tracking
(blocking-b2g:1.3+, firefox27 wontfix, firefox28 fixed, firefox29 fixed, b2g18 wontfix, b2g-v1.1hd wontfix, b2g-v1.2 wontfix, b2g-v1.3 fixed, b2g-v1.4 fixed)
People
(Reporter: gsvelto, Assigned: gsvelto)
References
Details
Attachments
(1 file, 4 obsolete files)
2.19 KB,
patch
|
gsvelto
:
review+
|
Details | Diff | Splinter Review |
+++ This bug was initially created as a clone of Bug #947234 +++
As discussed on bug 947234 we need a way to retrieve the message threads starting from the most recent as they are currently provided in the opposite order. I'll post two patches for this and we'll evaluate which one we want to land depending on risk and API considerations:
- The first one just reverses the order in which threads are delivered; since to my knowledge the order is not specified in any documentation this should be OK and is a very low-risk fix (a one line change basically).
- The second one adds a parameter to mozMobileMessage.getThreads() that specifies the direction used for retrieving the threads. This would be more consistent with mozMobileMessage.getMessages() but carries a higher risk and changes the visible API (which this late in the 1.3 timeline doesn't feel right).
Assignee | ||
Comment 1•11 years ago
|
||
First patch, this is the one-line fix that reverts the order of retrieval. I've quickly tested on my phone and it seems to work fine, more testing is needed though.
Attachment #8364937 -
Flags: review?(gene.lian)
Assignee | ||
Comment 2•11 years ago
|
||
(In reply to Gabriele Svelto [:gsvelto] from comment #1)
> First patch, this is the one-line fix that reverts the order of retrieval.
^^^^^^^
I meant reverses
Updated•11 years ago
|
Attachment #8364937 -
Flags: review?(gene.lian) → review+
Comment 3•11 years ago
|
||
Comment on attachment 8364937 [details] [diff] [review]
[PATCH] Revert the order of retrieval of message threads
Hi Vicamo, you should take a look.
Attachment #8364937 -
Flags: feedback?(vyang)
Assignee | ||
Comment 4•11 years ago
|
||
This is the second riskier patch that makes mozMobileMessage.getThreads() take an optional parameter |reverse| that returns threads in younger-to-older order. I've extended the marionette tests to cover this functionality and I'm in the process of testing this.
Not asking for review just yet as I'd like to get feedback first on how to proceed. Note that if we take this patch over the simpler the patch-set in bug 947234 requires a couple of minor changes too.
Attachment #8365069 -
Flags: feedback?(vyang)
Assignee | ||
Comment 5•11 years ago
|
||
Nom'ing this now that the patches are ready; Fabrice could you tell me how to proceed here since this might require uplifting one of the two patches here to mozilla-b2g28_v1_3. Here's a description of the problem and related possibilities and risks:
In bug 947234 I've prepared a patch-set that displays incrementally the message threads as they come off the cursor, this dramatically speeds up application startup especially with large number of threads (the time to display the first thread in the x-heavy workload goes from 9+ seconds to ~400ms). The downside of this approach is that Gecko currently delivers threads in order starting from the oldest ones; this causes the user to be presented with older threads first which is quite unpleasant.
To move forward we've got three possible options:
- Leave things as they are, land only the gaia patches in bug 947234 and stick with the unpleasant but working behavior. This is obviously the less risky option.
- Take attachment 8364937 [details] [diff] [review] and uplift it to mozilla-b2g28_v1_3, this is a one line fix that reverses the order in which threads are iterated by mozMobileMessage.getThreads() and thus provides the behavior we need in bug 947234 with minimal risk. Changing the visible behavior of that method shouldn't affect other code because AFAIK the SMS app is its only user.
- Take 8365069 and uplift it to mozilla-b2g28_v1_3. This is a more "proper" fix that adds an optional parameter to mozMobileMessage.getThreads() to specify the direction we want to use for iteration. This has the upside of not changing the behavior of the method when called w/o parameters but requires more extensive changes in Gecko. From an API perspective this is more consistent with mozMobileMessage.getMessages() but still means we're changing a public API very late in the 1.3 cycle which feels a bit awkward.
Status: NEW → ASSIGNED
blocking-b2g: --- → 1.3?
Flags: needinfo?(fabrice)
Comment 6•11 years ago
|
||
Comment on attachment 8364937 [details] [diff] [review]
[PATCH] Revert the order of retrieval of message threads
Review of attachment 8364937 [details] [diff] [review]:
-----------------------------------------------------------------
I think it will at least fails "dom/mobilemessage/tests/marionette/test_getthreads.js" because thread ordering is also considered in that test script. But I think you'll only need a line |checkFuncs.reverse()| to fix it.
Attachment #8364937 -
Flags: feedback?(vyang) → feedback-
Comment 7•11 years ago
|
||
(In reply to Gabriele Svelto [:gsvelto] from comment #5)
> - Take 8365069 and uplift it to mozilla-b2g28_v1_3. This is a more "proper"
> fix that adds an optional parameter to mozMobileMessage.getThreads() to
> specify the direction we want to use for iteration. This has the upside of
> not changing the behavior of the method when called w/o parameters but
> requires more extensive changes in Gecko. From an API perspective this is
> more consistent with mozMobileMessage.getMessages() but still means we're
> changing a public API very late in the 1.3 cycle which feels a bit awkward.
I think they're quite the same because Gaia has no way (except Gecko version) to detect either API change, so both of them result in an unknown behaviour. I mean passing an optional 'true' to that API doesn't guarantee that message threads are always returned in reversed order because one might just have a slightly outdated Gecko. Then it seems to me that preserving current API interface, that is, taking the one liner solution, would be a better idea for me. :)
Comment 8•11 years ago
|
||
Comment on attachment 8365069 [details] [diff] [review]
[PATCH alt] Add a paremeter to make mozMobileMessage.getThreads() return threads in reverse order
Review of attachment 8365069 [details] [diff] [review]:
-----------------------------------------------------------------
But let's take the one liner way, shall we?
::: dom/mobilemessage/tests/marionette/test_getthreads.js
@@ +392,5 @@
>
> +// Check reverse access.
> +tasks.push(getAllThreads.bind(null, function(threads) {
> +{
> + is(threads.length, checkFuncs.length, "number of threads got");
should be |reverseCheckFuncs|.
@@ +400,5 @@
> + tasks.next();
> + return;
> + }
> +
> + checkFuncs.shift()(threads.shift(), callback);
ditto
Attachment #8365069 -
Flags: feedback?(vyang)
Assignee | ||
Comment 9•11 years ago
|
||
Thanks for the feedback Vicamo, I'm also keener on the one-line patch as it doesn't change the external interface. And yes the marionette tests are broken in both patches. I'm fixing them up right now; unfortunately running tests in the emulator is slooow... :(
Comment 10•11 years ago
|
||
(In reply to Vicamo Yang [:vicamo][:vyang] from comment #7)
> (In reply to Gabriele Svelto [:gsvelto] from comment #5)
> > - Take 8365069 and uplift it to mozilla-b2g28_v1_3. This is a more "proper"
> > fix that adds an optional parameter to mozMobileMessage.getThreads() to
> > specify the direction we want to use for iteration. This has the upside of
> > not changing the behavior of the method when called w/o parameters but
> > requires more extensive changes in Gecko. From an API perspective this is
> > more consistent with mozMobileMessage.getMessages() but still means we're
> > changing a public API very late in the 1.3 cycle which feels a bit awkward.
>
> I think they're quite the same because Gaia has no way (except Gecko
> version) to detect either API change, so both of them result in an unknown
> behaviour. I mean passing an optional 'true' to that API doesn't guarantee
> that message threads are always returned in reversed order because one might
> just have a slightly outdated Gecko. Then it seems to me that preserving
> current API interface, that is, taking the one liner solution, would be a
> better idea for me. :)
The only user of this API is the SMS app so I'd rather favor consistency over the public API debate. (so, the opposite advice).
That said, I've no strong opinion so as long as we move forward I am happy.
Assignee | ||
Comment 11•11 years ago
|
||
Updated patch with the marionette test fixed, carried over the r+ flag.
Attachment #8364937 -
Attachment is obsolete: true
Attachment #8365202 -
Flags: review+
Attachment #8365202 -
Flags: feedback?(vyang)
Updated•11 years ago
|
Attachment #8365202 -
Flags: feedback?(vyang) → feedback+
Assignee | ||
Comment 12•11 years ago
|
||
Alternate patch adding the |reverse| parameter, now with updated tests working properly.
Attachment #8365069 -
Attachment is obsolete: true
Comment 13•11 years ago
|
||
(In reply to Gabriele Svelto [:gsvelto] from comment #12)
> Created attachment 8365313 [details] [diff] [review]
> [PATCH alt v2] Add a paremeter to make mozMobileMessage.getThreads() return
> threads in reverse order
>
> Alternate patch adding the |reverse| parameter, now with updated tests
> working properly.
Just to clarify, this means that the public facing API will look something like these:
mozMobileMessage.getThreads(true);
mozMobileMessage.getThreads(false);
If you didn't write this patch and had never seen this, would you have any idea at all what `true` or `false` meant here? What happens when we need another getThreads filter or operational mechanism? This is a well known anti-pattern that should be avoided[0].
Please use an "options object"; this makes it obvious to the reader and is not future hostile:
mozMobileMessage.getThreads({ reverse: true });
mozMobileMessage.getThreads({ reverse: false }); // this is the default
[0] http://ariya.ofilabs.com/2011/08/hall-of-api-shame-boolean-trap.html
Comment 14•11 years ago
|
||
I'm fine with taking the "one line" fix on 1.3, but not the other one.
Flags: needinfo?(fabrice)
Assignee | ||
Comment 15•11 years ago
|
||
(In reply to Fabrice Desré [:fabrice] from comment #14)
> I'm fine with taking the "one line" fix on 1.3, but not the other one.
Thanks Fabrice, I'm obsoleting the other patch and I've fixed the comment on this one (revert -> reverse), carrying over the r+ flag. This is the try run:
https://tbpl.mozilla.org/?tree=Try&rev=bb6da2773e73
Attachment #8365202 -
Attachment is obsolete: true
Attachment #8365313 -
Attachment is obsolete: true
Attachment #8366122 -
Flags: review+
Assignee | ||
Comment 17•11 years ago
|
||
Try is green, ready for landing. This needs to land on mozilla-b2g28_v1_3 too.
Keywords: checkin-needed
Assignee | ||
Comment 18•11 years ago
|
||
(In reply to Rick Waldron [:rwaldron] from comment #13)
> If you didn't write this patch and had never seen this, would you have any
> idea at all what `true` or `false` meant here? What happens when we need
> another getThreads filter or operational mechanism? This is a well known
> anti-pattern that should be avoided[0].
>
> Please use an "options object"; this makes it obvious to the reader and is
> not future hostile:
>
> mozMobileMessage.getThreads({ reverse: true });
>
> mozMobileMessage.getThreads({ reverse: false }); // this is the default
This is a very good point and a pattern I'll keep in mind, thanks for pointing it out. Coming from a mainly C/C++ background I was used to replacing booleans with enums to clarify the parameter's meaning but in JS this wasn't available and I hadn't thought about this pattern.
Comment 19•11 years ago
|
||
(In reply to Rick Waldron [:rwaldron] from comment #13)
> Please use an "options object"; this makes it obvious to the reader and is
> not future hostile:
>
> mozMobileMessage.getThreads({ reverse: true });
> mozMobileMessage.getThreads({ reverse: false }); // this is the default
That's even better. I'll f+ or r+ this once it's uploaded.
Comment 20•11 years ago
|
||
Flags: in-testsuite+
Keywords: checkin-needed
Assignee | ||
Comment 21•11 years ago
|
||
(In reply to Vicamo Yang [:vicamo][:vyang] from comment #19)
> That's even better. I'll f+ or r+ this once it's uploaded.
OK, so to keep the scope of this bug small I'll open a follow-up bug and move attachment 8365313 [details] [diff] [review] there. To keep the API consistent I'll open a follow up where I propose to add an optional object to specify the ordering of threads (as described above) and I'll also propose to change the second parameter of getMessages() [1] in a similar way for consistency. I'll shoot an e-mail to the dev-webapi list too.
[1] It's currently a boolean called |reverse|, changing it too will improve readability as Rick suggested
Comment 22•11 years ago
|
||
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → 1.3 C3/1.4 S3(31jan)
Comment 23•11 years ago
|
||
https://hg.mozilla.org/releases/mozilla-aurora/rev/a20477cb1190
You might want to take a look at this for sanity as Aurora doesn't have MobileMessageDB.jsm and this therefore required some fixing up :).
Assignee | ||
Comment 24•11 years ago
|
||
(In reply to Ryan VanderMeulen [:RyanVM UTC-5] from comment #23)
> https://hg.mozilla.org/releases/mozilla-aurora/rev/a20477cb1190
>
> You might want to take a look at this for sanity as Aurora doesn't have
> MobileMessageDB.jsm and this therefore required some fixing up :).
It's looking good, thank you very much!
You need to log in
before you can comment on or make changes to this bug.
Description
•