VulpesOS/gaia/apps/communications/contacts/js/migrator.js
OverSu b38dea0597 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.
2026-09-30 23:13:03 +02:00

49 lines
1.2 KiB
JavaScript
Executable file

'use strict';
/* global fb, utils, LazyLoader, DatastoreMigration, ImportStatusData*/
/* exported Migrator */
var Migrator = (function(){
var start = function start(config) {
if (!config || !config.fbMigrated) {
migrateFbContacts();
}
if (!config || !config.accessTokenMigrated) {
migrateFbToken();
}
};
function migrateFbContacts() {
LazyLoader.load('js/fb/datastore_migrator.js', function() {
new DatastoreMigration().start();
});
}
function migrateFbToken() {
LazyLoader.load([
'/shared/js/contacts/import/import_status_data.js',
], function() {
var STORAGE_KEY = fb.utils.TOKEN_DATA_KEY;
ImportStatusData.get(STORAGE_KEY).then(function(datastoreToken) {
if (!datastoreToken) {
utils.cookie.update({accessTokenMigrated: true});
window.asyncStorage.getItem(STORAGE_KEY, function(asyncstorageToken) {
if (asyncstorageToken) {
ImportStatusData.put(STORAGE_KEY, asyncstorageToken).then(
function() {
window.asyncStorage.removeItem(STORAGE_KEY);
});
}
});
}
});
});
}
return {
start: start
};
})();