From 304a8df808021a6a80fea5d1023743dbf41e45fd Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 11 Sep 2017 14:25:19 +0200 Subject: [PATCH] Remove unneeded migration and fix attributes migration --- www/common/migrate-user-object.js | 51 ++++++++++--------------------- 1 file changed, 16 insertions(+), 35 deletions(-) diff --git a/www/common/migrate-user-object.js b/www/common/migrate-user-object.js index cc088c7c5..fd469b07c 100644 --- a/www/common/migrate-user-object.js +++ b/www/common/migrate-user-object.js @@ -44,57 +44,38 @@ define([], function () { userObject.version = version = 1; } - - // 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 + // Migration 2: global attributes from root to 'settings' subobjects var migrateAttributes = function () { var drawer = 'cryptpad.userlist-drawer'; var polls = 'cryptpad.hide_poll_text'; - var indentKey = 'indentUnit'; - var useTabsKey = 'indentWithTabs'; + var indentKey = 'cryptpad.indentUnit'; + var useTabsKey = 'cryptpad.indentWithTabs'; var settings = userObject.settings = userObject.settings || {}; - if (settings[indentKey] || settings[useTabsKey]) { + if (typeof(userObject[indentKey]) !== "undefined") { settings.codemirror = settings.codemirror || {}; - settings.codemirror.indentUnit = settings[indentKey]; - settings.codemirror.indentWithTabs = settings[useTabsKey]; - delete settings[indentKey]; - delete settings[useTabsKey]; + settings.codemirror.indentUnit = userObject[indentKey]; + delete userObject[indentKey]; } - 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['userlist-drawer'] = userObject[drawer]; delete userObject[drawer]; } - if (userObject[polls]) { + if (typeof(userObject[polls]) !== "undefined") { settings.poll = settings.poll || {}; settings.poll['hide-text'] = userObject[polls]; delete userObject[polls]; } }; - if (version < 3) { + if (version < 2) { migrateAttributes(); - Cryptpad.feedback('Migrate-3', true); - userObject.version = version = 3; + Cryptpad.feedback('Migrate-2', true); + userObject.version = version = 2; } }; });