Closed
Bug 860806
Opened 12 years ago
Closed 11 years ago
can't search for the internationalized number when the local number is stored, and vice versa
Categories
(Core :: DOM: Device Interfaces, defect)
Tracking
()
RESOLVED
WORKSFORME
blocking-b2g | koi+ |
People
(Reporter: julienw, Assigned: gwagner)
References
Details
(Whiteboard: c=contacts)
Attachments
(1 file)
(deleted),
patch
|
reuben
:
review+
bent.mozilla
:
review+
|
Details | Diff | Splinter Review |
STR:
* have a contact with a number +336123456789
* in the SMS app, search for 06123456
Expected:
* we should find this contact
Actual:
* we don't
A quick fix would be to remove the leading 0 if present, either in SMS app, or in the Contacts API. I think fixing this in the Contacts API makes more sense.
Comment 1•12 years ago
|
||
Is this related to "contains" actually being a "startsWith"?
Updated•12 years ago
|
status-b2g18:
--- → affected
Reporter | ||
Comment 2•12 years ago
|
||
(In reply to Rick Waldron from comment #1)
> Is this related to "contains" actually being a "startsWith"?
Nope, the phone search is actually a "contains" ;)
Comment 3•12 years ago
|
||
(In reply to Julien Wajsberg [:julienw] from comment #0)
> STR:
> * have a contact with a number +336123456789
> * in the SMS app, search for 06123456
>
> Expected:
> * we should find this contact
>
> Actual:
> * we don't
>
> A quick fix would be to remove the leading 0 if present, either in SMS app,
> or in the Contacts API. I think fixing this in the Contacts API makes more
> sense.
Hi Julien, I am looking to take this bug and from my initial skim through the code and the implementation of a quick fix (i.e. drop the leading '0', if present, when searching, as you mentioned) I noticed that:
1. if the fix is in the contacts API (apps/sms/js/contacts.js#L182), the found contacts don't have the matching substring highlighted
2. if the fix is in the rendering of the search results (i.e. drop the leading '0' before sending the input string to the contacts API), the matching substring is highlighted without the leading '0', thus leading to cases where a search for '0654' for contacts that have local numbers, e.g. '0654455215', would only highlight '654'.
These two approaches are considering a solution on Gaia's side. I guess an extra check in Gecko's implementation of ContactsManager.find (cf. https://wiki.mozilla.org/ContactsAPI#API) for the leading '0' would also do the trick.
What do you think about this, should I follow one of the two points I mentioned above and eventually refactor the substring highlighting code to work correctly, or leave this for a fix in Gecko by someone else?
Flags: needinfo?(felash)
Assignee | ||
Updated•12 years ago
|
Blocks: b2g-contact
Reporter | ||
Comment 4•12 years ago
|
||
Mihai, what I call the "contacts API" is in gecko ;)
I'd love to know what Gregor thinks about it: should this be fixed in the Gecko Contacts API as I think, or should we implement a workaround in Gaia ?
Thanks !
Flags: needinfo?(felash) → needinfo?(anygregor)
Assignee | ||
Comment 5•12 years ago
|
||
Yeah we can handle this in the contacts api. We just have to add the national format to the search space for the contains.
Flags: needinfo?(anygregor)
Comment 6•12 years ago
|
||
Yea, bug 862250 will add support this with a "match" filterOp for telephone numbers.
(In reply to Julien Wajsberg [:julienw] from comment #2)
> (In reply to Rick Waldron from comment #1)
> > Is this related to "contains" actually being a "startsWith"?
>
> Nope, the phone search is actually a "contains" ;)
Not really. For "123", and a saved contact with phone "54123", it'll try to match numbers lexicographically larger than "123" and smaller than "124", where "numbers" for this contact would be the array ["54123", "4123", "123", "23", "3"]. In this case, it's a successful match, but "0123" would not work.
It's more like "endsWith a string that startsWith the entire number".
Assignee | ||
Updated•12 years ago
|
Assignee: nobody → anygregor
Assignee | ||
Comment 7•12 years ago
|
||
Assignee | ||
Updated•12 years ago
|
Attachment #741879 -
Flags: review?(reuben.bmo)
Attachment #741879 -
Flags: review?(bent.mozilla)
Comment 8•12 years ago
|
||
Comment on attachment 741879 [details] [diff] [review]
patch
Review of attachment 741879 [details] [diff] [review]:
-----------------------------------------------------------------
Thanks, r=me with these fixed.
We should clean up that "special case telephone number" code when we don't have to worry about uplift hell anymore.
::: dom/contacts/fallback/ContactDB.jsm
@@ +317,5 @@
> db.createObjectStore(SAVED_GETALL_STORE_NAME);
> + } else if (currVersion == 8) {
> + if (DEBUG) debug("Adding national format to contains search.");
> + if (!objectStore) {
> + objectStore = aTransaction.objectStore(STORE_NAME);
The indentation is off by 1 space throughout the rest of this chunk, please fix this.
@@ +331,5 @@
> + let parsedNumber = PhoneNumberUtils.parse(number);
> + if (parsedNumber &&
> + parsedNumber.nationalFormat &&
> + number !== parsedNumber.nationalFormat) {
> + let digits = parsedNumber.nationalFormat.match(/\d/g);
Can you do normalize here instead of using the RegExp? That way we don't even get to the loop for the case where nationalFormat and number only differ in whitespace and formatting characters.
@@ +487,5 @@
> }
> }
> }
> + if (parsedNumber.nationalFormat &&
> + number.toString() !== parsedNumber.nationalFormat) {
You don't need the toString() here. There's a |number = number.toString();| in the beginning of the if now.
@@ +492,5 @@
> + let digits = parsedNumber.nationalFormat.match(/\d/g);
> + if (digits) {
> + digits = digits.join('');
> + for(let i = 0; i < digits.length; i++) {
> + search[digits.substring(i, digits.length)] = 1;
Again, you want to normalize before comparing instead of doing the RegExp, because this should only be added when number and nationalFormat differ in significant characters.
::: dom/contacts/tests/test_contacts_basics.html
@@ +781,5 @@
> + req = mozContacts.find(options);
> + req.onsuccess = function () {
> + is(req.result.length, 1, "Found exactly 1 contact.");
> + findResult1 = req.result[0];
> + ok(findResult1.id == sample_id1, "Same ID");
Use is() in these ID checks please.
@@ +820,5 @@
> + },
> + function () {
> + ok(true, "Deleting database");
> + req = mozContacts.clear();
> + req.onsuccess = function () {
Nit: extra space.
Attachment #741879 -
Flags: review?(reuben.bmo) → review+
Comment on attachment 741879 [details] [diff] [review]
patch
Review of attachment 741879 [details] [diff] [review]:
-----------------------------------------------------------------
::: dom/contacts/fallback/ContactDB.jsm
@@ +344,5 @@
> + }
> + }
> + }
> + )
> + cursor.update(cursor.value);
There's no need to call this if you don't modify tel. It's just going to slow everything down.
@@ +491,5 @@
> + number.toString() !== parsedNumber.nationalFormat) {
> + let digits = parsedNumber.nationalFormat.match(/\d/g);
> + if (digits) {
> + digits = digits.join('');
> + for(let i = 0; i < digits.length; i++) {
Nit: space after for.
Attachment #741879 -
Flags: review?(bent.mozilla) → review+
Reporter | ||
Comment 10•12 years ago
|
||
I'm quite sure this should block 1.1 => nominating for leo.
blocking-b2g: --- → leo?
Comment 11•12 years ago
|
||
(In reply to Julien Wajsberg [:julienw] from comment #10)
> I'm quite sure this should block 1.1 => nominating for leo.
Can you provide the regressing bug for posterity?
Reporter | ||
Comment 12•12 years ago
|
||
Alex> Not really, sorry. I don't know if that ever works, indeed.
Reporter | ||
Comment 13•12 years ago
|
||
*worked
Comment 14•12 years ago
|
||
Adding c=contacts whiteboard to get this into the scrumbugs backlog.
Whiteboard: c=contacts
Comment 15•12 years ago
|
||
Triage - referring to FFOS Product to see if this is required? based on comment 12 unable to know if this is a regression.
Flags: needinfo?(ffos-product)
Comment 16•12 years ago
|
||
I'd like UX's input on this. Personally, I see this as important, but not critical.
Flags: needinfo?(ffos-product) → needinfo?(firefoxos-ux-bugzilla)
Reporter | ||
Comment 17•12 years ago
|
||
this is a device interfaces bug
Component: Gaia::SMS → DOM: Device Interfaces
Product: Boot2Gecko → Core
Assignee | ||
Comment 18•12 years ago
|
||
We supported it but we had to remove it in bug 864695.
Comment 19•12 years ago
|
||
based on comment# 16 will not be blocking, but can be nominated for uplift and will be considered based on the risk
blocking-b2g: leo? → -
Comment 20•12 years ago
|
||
Does comment 17 (i.e. device interface bug) mean that UX is no longer needed, and that the source of the issue has been determined? Please let me know. Thanks!
Updated•12 years ago
|
Flags: needinfo?(firefoxos-ux-bugzilla)
Reporter | ||
Comment 21•11 years ago
|
||
I think this bug is now obsolete ?
Comment 24•11 years ago
|
||
(In reply to Julien Wajsberg [:julienw] from comment #23)
> blocking koi+ bug 904515
I think you resetted to koi? by mistake :(
Flags: needinfo?(felash)
Reporter | ||
Comment 28•11 years ago
|
||
Soooo should we close it and check if bug 904515 just works ?
Assignee | ||
Comment 29•11 years ago
|
||
Yes please retest.
Assignee | ||
Comment 30•11 years ago
|
||
(In reply to Julien Wajsberg [:julienw] from comment #0)
> STR:
> * have a contact with a number +336123456789
> * in the SMS app, search for 06123456
>
The API supports this now with the 'match' functionality.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•