Bug 769805 - Contacts API broken due to IndexedDB API Change. r=khuey

This commit is contained in:
Guillermo Lopez 2012-07-02 12:03:49 -07:00
parent b3808e2e18
commit f47fee5145

View File

@ -308,21 +308,21 @@ ContactDB.prototype = {
let request; let request;
if (key == "id") { if (key == "id") {
// store.get would return an object and not an array // store.get would return an object and not an array
request = store.getAll(options.filterValue); request = store.mozGetAll(options.filterValue);
} else if (key == "category") { } else if (key == "category") {
let index = store.index(key); let index = store.index(key);
request = index.getAll(options.filterValue, limit); request = index.mozGetAll(options.filterValue, limit);
} else if (options.filterOp == "equals") { } else if (options.filterOp == "equals") {
debug("Getting index: " + key); debug("Getting index: " + key);
// case sensitive // case sensitive
let index = store.index(key); let index = store.index(key);
request = index.getAll(options.filterValue, limit); request = index.mozGetAll(options.filterValue, limit);
} else { } else {
// not case sensitive // not case sensitive
let tmp = options.filterValue.toLowerCase(); let tmp = options.filterValue.toLowerCase();
let range = this._global.IDBKeyRange.bound(tmp, tmp + "\uFFFF"); let range = this._global.IDBKeyRange.bound(tmp, tmp + "\uFFFF");
let index = store.index(key + "LowerCase"); let index = store.index(key + "LowerCase");
request = index.getAll(range, limit); request = index.mozGetAll(range, limit);
} }
if (!txn.result) if (!txn.result)
txn.result = {}; txn.result = {};
@ -341,7 +341,7 @@ ContactDB.prototype = {
txn.result = {}; txn.result = {};
// Sorting functions takes care of limit if set. // Sorting functions takes care of limit if set.
let limit = options.sortBy === 'undefined' ? options.filterLimit : null; let limit = options.sortBy === 'undefined' ? options.filterLimit : null;
store.getAll(null, limit).onsuccess = function (event) { store.mozGetAll(null, limit).onsuccess = function (event) {
debug("Request successful. Record count:", event.target.result.length); debug("Request successful. Record count:", event.target.result.length);
for (let i in event.target.result) for (let i in event.target.result)
txn.result[event.target.result[i].id] = this.makeExport(event.target.result[i]); txn.result[event.target.result[i].id] = this.makeExport(event.target.result[i]);