Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
75
gaia/apps/system/js/app_migrator.js
Executable file
75
gaia/apps/system/js/app_migrator.js
Executable file
|
|
@ -0,0 +1,75 @@
|
|||
'use strict';
|
||||
/* global Service */
|
||||
|
||||
/**
|
||||
The app migrator is in charge of migrating app data between releases
|
||||
*/
|
||||
|
||||
(function(exports) {
|
||||
|
||||
const HOMESCREEN_MANIFEST =
|
||||
'app://homescreen.gaiamobile.org/manifest.webapp';
|
||||
|
||||
const VERTICALHOME_PREFS_STORE = 'vertical_preferences_store';
|
||||
|
||||
const MIGRATION_PREF = 'migrated';
|
||||
|
||||
var AppMigrator = function AppMigrator() {
|
||||
};
|
||||
|
||||
AppMigrator.prototype = {
|
||||
|
||||
start: function() {
|
||||
// Probably should not happen, but just to be safe we early exit in case
|
||||
// we get a second migrate message.
|
||||
if (this.migrating) {
|
||||
return;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
if (Service.query('justUpgraded')) {
|
||||
self.migrating = true;
|
||||
|
||||
// Migrate to new home screen if migration hasn't already been
|
||||
// performed.
|
||||
navigator.getDataStores(VERTICALHOME_PREFS_STORE).then(
|
||||
stores => {
|
||||
if (stores.length < 1) {
|
||||
console.error('Error opening verticalhome prefs datastore');
|
||||
return;
|
||||
}
|
||||
|
||||
var migrate = () => {
|
||||
navigator.mozApps.getSelf().onsuccess = e => {
|
||||
var app = e.target.result;
|
||||
if (!app) {
|
||||
console.error('Error retrieving app object');
|
||||
return;
|
||||
}
|
||||
|
||||
app.connect('verticalhome-migrate').then(ports => {
|
||||
ports.forEach(port => {
|
||||
port.postMessage({ action: 'migrate',
|
||||
manifestURL: HOMESCREEN_MANIFEST });
|
||||
});
|
||||
}, e => {
|
||||
console.error('Error communicating with verticalhome', e);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
stores[0].get(MIGRATION_PREF).then(
|
||||
migrated => {
|
||||
if (!migrated) {
|
||||
migrate();
|
||||
}
|
||||
}, e => {
|
||||
console.error('Error getting verticalhome migration pref', e);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
exports.AppMigrator = AppMigrator;
|
||||
|
||||
})(window);
|
||||
Loading…
Reference in a new issue