Created
September 24, 2014 15:40
-
-
Save rik/7104ef76d720ce113684 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apps/communications/dialer/js/call_log_db.js | 60 ++++++++++++++-------------- | |
1 file changed, 29 insertions(+), 31 deletions(-) | |
diff --git a/apps/communications/dialer/js/call_log_db.js b/apps/communications/dialer/js/call_log_db.js | |
index 7f3ad2c..5404f30 100644 | |
--- a/apps/communications/dialer/js/call_log_db.js | |
+++ b/apps/communications/dialer/js/call_log_db.js | |
@@ -2,14 +2,14 @@ | |
/* exported CallLogDBManager */ | |
-/*global ContactPhotoHelper, Contacts, IDBKeyRange, LazyLoader, Utils */ | |
+/*global Contacts, LazyLoader, Utils */ | |
var CallLogDBManager = { | |
_db: null, | |
_dbName: 'dialerRecents', | |
_dbRecentsStore: 'dialerRecents', | |
_dbGroupsStore: 'dialerGroups', | |
- _dbVersion: 5, | |
+ _dbVersion: 6, | |
_maxNumberOfGroups: 200, | |
_numberOfGroupsToDelete: 30, | |
@@ -138,6 +138,9 @@ var CallLogDBManager = { | |
self._upgradeSchemaVersion5(next); | |
break; | |
case 5: | |
+ self._upgradeSchemaVersion6(db, txn, next); | |
+ break; | |
+ case 6: | |
// we have finished the upgrades. please keep this | |
// in sync for future upgrades, since otherwise it | |
// will call the default: and abort the transaction :( | |
@@ -294,8 +297,11 @@ var CallLogDBManager = { | |
return; | |
} | |
+ debugger; | |
+ console.log('onGroupsDone executed') | |
+ | |
if (groupCount === 0) { | |
- next(); | |
+ setTimeout(next); | |
return; | |
} | |
@@ -311,7 +317,7 @@ var CallLogDBManager = { | |
var onPutSuccess = function onsuccess() { | |
groupCount--; | |
if (groupCount === 0) { | |
- next(); | |
+ setTimeout(next); | |
} | |
}; | |
for (var group in groups) { | |
@@ -354,6 +360,7 @@ var CallLogDBManager = { | |
// finish before pushing the data to the groups object store. We will | |
// notify the UI about that so it can request the data again. | |
cursorDone = true; | |
+ console.log('onGroupsDone Cursor') | |
onGroupsDone(); | |
return; | |
} | |
@@ -420,10 +427,6 @@ var CallLogDBManager = { | |
}; | |
if (contact && contact !== null) { | |
group.contactId = contact.id; | |
- var photo = ContactPhotoHelper.getThumbnail(contact); | |
- if (photo) { | |
- group.contactPhoto = photo; | |
- } | |
if (matchingTel) { | |
var primaryInfo = Utils.getPhoneNumberPrimaryInfo(matchingTel, | |
contact); | |
@@ -443,6 +446,7 @@ var CallLogDBManager = { | |
groupCount++; | |
} | |
waitForAsyncCall--; | |
+ console.log('onGroupsDone contacts') | |
onGroupsDone(); | |
}); | |
cursor.continue(); | |
@@ -484,6 +488,23 @@ var CallLogDBManager = { | |
_upgradeSchemaVersion5: function upgradeSchemaVersion5(next) { | |
next(); | |
}, | |
+ | |
+ _upgradeSchemaVersion6: function(db, transaction, next) { | |
+ var groupsStore = transaction.objectStore(this._dbGroupsStore); | |
+ groupsStore.openCursor().onsuccess = function(evt) { | |
+ var cursor = evt.target.result; | |
+ | |
+ // All done | |
+ if (!cursor) { | |
+ next(); | |
+ return; | |
+ } | |
+ | |
+ console.log(cursor.key, cursor.value.contactPhoto); | |
+ cursor.continue(); | |
+ }; | |
+ }, | |
+ | |
/** | |
* Helper function to get the group ID from a recent call object. | |
*/ | |
@@ -509,7 +530,6 @@ var CallLogDBManager = { | |
* contactPrimaryInfo: <String>, | |
* contactMatchingTelType: <String>, | |
* contactMatchingTelCarrier: <String>, | |
- * contactPhoto: <Blob>, | |
* emergency: <Bool>, | |
* voicemail: <Bool>, | |
* calls: [ | |
@@ -538,7 +558,6 @@ var CallLogDBManager = { | |
* type: <String>, | |
* carrier: <String> | |
* }, | |
- * photo: <Blob> | |
* }, | |
* emergency: <Bool>, | |
* voicemail: <Bool> | |
@@ -568,7 +587,6 @@ var CallLogDBManager = { | |
type: group.contactMatchingTelType, | |
carrier: group.contactMatchingTelCarrier | |
}, | |
- photo: group.contactPhoto | |
}; | |
} | |
@@ -718,10 +736,6 @@ var CallLogDBManager = { | |
function(contact, matchingTel) { | |
if (contact && contact !== null) { | |
group.contactId = contact.id; | |
- var photo = ContactPhotoHelper.getThumbnail(contact); | |
- if (photo) { | |
- group.contactPhoto = photo; | |
- } | |
if (matchingTel) { | |
var primaryInfo = Utils.getPhoneNumberPrimaryInfo(matchingTel, | |
contact); | |
@@ -1234,10 +1248,6 @@ var CallLogDBManager = { | |
if (cursor && cursor.value) { | |
var group = cursor.value; | |
group.contactId = contact.id; | |
- var photo = ContactPhotoHelper.getThumbnail(contact); | |
- if (photo) { | |
- group.contactPhoto = photo; | |
- } | |
if (matchingTel) { | |
var primaryInfo = Utils.getPhoneNumberPrimaryInfo(matchingTel, | |
contact); | |
@@ -1327,9 +1337,6 @@ var CallLogDBManager = { | |
if (group.contactMatchingTelCarrier) { | |
delete group.contactMatchingTelCarrier; | |
} | |
- if (group.contactPhoto) { | |
- delete group.contactPhoto; | |
- } | |
cursor.update(group); | |
count++; | |
cursor.continue(); | |
@@ -1383,10 +1390,6 @@ var CallLogDBManager = { | |
needsUpdate = true; | |
delete group.contactId; | |
} | |
- if (group.contactPhoto) { | |
- needsUpdate = true; | |
- delete group.contactPhoto; | |
- } | |
if (group.contactPrimaryInfo) { | |
needsUpdate = true; | |
delete group.contactPrimaryInfo; | |
@@ -1401,11 +1404,6 @@ var CallLogDBManager = { | |
} | |
} else { | |
group.contactId = contact.id; | |
- var photo = ContactPhotoHelper.getThumbnail(contact); | |
- if (photo && group.contactPhoto != photo) { | |
- group.contactPhoto = photo; | |
- needsUpdate = true; | |
- } | |
var primaryInfo = Utils.getPhoneNumberPrimaryInfo(matchingTel, | |
contact); | |
if (Array.isArray(primaryInfo) && primaryInfo[0]) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment