mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1193503
- Share activities from dialer, music, video, and gallery list duplicate options after OTA update. r=fabrice
This commit is contained in:
parent
72c7fe27b6
commit
1adeb6246e
@ -67,15 +67,18 @@ ActivitiesDb.prototype = {
|
||||
|
||||
let self = this;
|
||||
|
||||
/**
|
||||
* WARNING!! Before upgrading the Activities DB take into account that an
|
||||
* OTA unregisters all the activities and reinstalls them during the first
|
||||
* run process. Check Bug 1193503.
|
||||
*/
|
||||
|
||||
function upgrade(currentVersion) {
|
||||
let next = upgrade.bind(self, currentVersion + 1);
|
||||
switch (currentVersion) {
|
||||
case 0:
|
||||
self.createSchema(aDb, next);
|
||||
break;
|
||||
case 1:
|
||||
self.upgradeSchemaVersion2(aDb, aTransaction, next);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,47 +97,6 @@ ActivitiesDb.prototype = {
|
||||
aNext();
|
||||
},
|
||||
|
||||
upgradeSchemaVersion2: function(aDb, aTransaction, aNext) {
|
||||
debug("Upgrading DB to version 2");
|
||||
|
||||
// In order to be able to have multiple activities with same name
|
||||
// but different descriptions, we need to update the keypath from
|
||||
// a hash made from {manifest, name} to a hash made from {manifest,
|
||||
// name, description}.
|
||||
//
|
||||
// Unfortunately, updating the keypath is not allowed by IDB, so we
|
||||
// need to remove and recreate the activities object store.
|
||||
|
||||
let activities = [];
|
||||
let objectStore = aTransaction.objectStore(STORE_NAME);
|
||||
objectStore.openCursor().onsuccess = (event) => {
|
||||
let cursor = event.target.result;
|
||||
if (!cursor) {
|
||||
aDb.deleteObjectStore(STORE_NAME);
|
||||
|
||||
let objectStore = aDb.createObjectStore(STORE_NAME, { keyPath: "id" });
|
||||
|
||||
// indexes
|
||||
objectStore.createIndex("name", "name", { unique: false });
|
||||
objectStore.createIndex("manifest", "manifest", { unique: false });
|
||||
|
||||
this.add(activities, () => {
|
||||
debug("DB upgraded to version 2");
|
||||
aNext();
|
||||
}, () => {
|
||||
dump("Error upgrading DB to version 2 " + error + "\n");
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let activity = cursor.value;
|
||||
debug("Upgrading activity " + JSON.stringify(activity));
|
||||
activity.id = this.createId(activity);
|
||||
activities.push(activity);
|
||||
cursor.continue();
|
||||
};
|
||||
},
|
||||
|
||||
// unique ids made of (uri, action)
|
||||
createId: function actdb_createId(aObject) {
|
||||
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"]
|
||||
|
Loading…
Reference in New Issue
Block a user