Remove unneeded migration and fix attributes migration

pull/1/head
yflory 7 years ago
parent 37dca9c155
commit 304a8df808

@ -44,57 +44,38 @@ define([], function () {
userObject.version = version = 1; userObject.version = version = 1;
} }
// Migration 2: global attributes from root to 'settings' subobjects
// Migration 2: indentation settings for CodeMirror moved from root to 'settings'
var migrateIndent = function () {
var indentKey = 'cryptpad.indentUnit';
var useTabsKey = 'cryptpad.indentWithTabs';
userObject.settings = userObject.settings || {};
if (userObject[indentKey]) {
userObject.settings.indentUnit = userObject[indentKey];
delete userObject[indentKey];
}
if (userObject[useTabsKey]) {
userObject.settings.indentWithTabs = userObject[useTabsKey];
delete userObject[useTabsKey];
}
};
if (version < 2) {
migrateIndent();
Cryptpad.feedback('Migrate-2', true);
userObject.version = version = 2;
}
// Migration 3: global attributes from root to 'settings' subobjects
var migrateAttributes = function () { var migrateAttributes = function () {
var drawer = 'cryptpad.userlist-drawer'; var drawer = 'cryptpad.userlist-drawer';
var polls = 'cryptpad.hide_poll_text'; var polls = 'cryptpad.hide_poll_text';
var indentKey = 'indentUnit'; var indentKey = 'cryptpad.indentUnit';
var useTabsKey = 'indentWithTabs'; var useTabsKey = 'cryptpad.indentWithTabs';
var settings = userObject.settings = userObject.settings || {}; var settings = userObject.settings = userObject.settings || {};
if (settings[indentKey] || settings[useTabsKey]) { if (typeof(userObject[indentKey]) !== "undefined") {
settings.codemirror = settings.codemirror || {}; settings.codemirror = settings.codemirror || {};
settings.codemirror.indentUnit = settings[indentKey]; settings.codemirror.indentUnit = userObject[indentKey];
settings.codemirror.indentWithTabs = settings[useTabsKey]; delete userObject[indentKey];
delete settings[indentKey];
delete settings[useTabsKey];
} }
if (userObject[drawer]) { if (typeof(userObject[useTabsKey]) !== "undefined") {
settings.codemirror = settings.codemirror || {};
settings.codemirror.indentWithTabs = userObject[useTabsKey];
delete userObject[useTabsKey];
}
if (typeof(userObject[drawer]) !== "undefined") {
settings.toolbar = settings.toolbar || {}; settings.toolbar = settings.toolbar || {};
settings.toolbar['userlist-drawer'] = userObject[drawer]; settings.toolbar['userlist-drawer'] = userObject[drawer];
delete userObject[drawer]; delete userObject[drawer];
} }
if (userObject[polls]) { if (typeof(userObject[polls]) !== "undefined") {
settings.poll = settings.poll || {}; settings.poll = settings.poll || {};
settings.poll['hide-text'] = userObject[polls]; settings.poll['hide-text'] = userObject[polls];
delete userObject[polls]; delete userObject[polls];
} }
}; };
if (version < 3) { if (version < 2) {
migrateAttributes(); migrateAttributes();
Cryptpad.feedback('Migrate-3', true); Cryptpad.feedback('Migrate-2', true);
userObject.version = version = 3; userObject.version = version = 2;
} }
}; };
}); });

Loading…
Cancel
Save