Merge branch 'soon'
commit
4ad0ba5c4a
@ -0,0 +1,13 @@
|
|||||||
|
.password_main() {
|
||||||
|
.cp-password-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
input {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
label, .fa {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,106 +1,152 @@
|
|||||||
define(['/common/common-feedback.js'], function (Feedback) {
|
define([
|
||||||
|
'/common/common-feedback.js',
|
||||||
|
'/common/common-hash.js',
|
||||||
|
'/common/common-util.js',
|
||||||
|
'/bower_components/nthen/index.js',
|
||||||
|
], function (Feedback, Hash, Util, nThen) {
|
||||||
// Start migration check
|
// Start migration check
|
||||||
// Versions:
|
// Versions:
|
||||||
// 1: migrate pad attributes
|
// 1: migrate pad attributes
|
||||||
// 2: migrate indent settings (codemirror)
|
// 2: migrate indent settings (codemirror)
|
||||||
|
|
||||||
return function (userObject) {
|
return function (userObject, cb, progress) {
|
||||||
var version = userObject.version || 0;
|
var version = userObject.version || 0;
|
||||||
|
|
||||||
// DEPRECATED
|
nThen(function () {
|
||||||
// Migration 1: pad attributes moved to filesData
|
// DEPRECATED
|
||||||
var migratePadAttributesToData = function () {
|
// Migration 1: pad attributes moved to filesData
|
||||||
return true;
|
var migratePadAttributesToData = function () {
|
||||||
};
|
return true;
|
||||||
if (version < 1) {
|
};
|
||||||
migratePadAttributesToData();
|
if (version < 1) {
|
||||||
}
|
migratePadAttributesToData();
|
||||||
|
|
||||||
// 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 = 'cryptpad.indentUnit';
|
|
||||||
var useTabsKey = 'cryptpad.indentWithTabs';
|
|
||||||
var settings = userObject.settings = userObject.settings || {};
|
|
||||||
if (typeof(userObject[indentKey]) !== "undefined") {
|
|
||||||
settings.codemirror = settings.codemirror || {};
|
|
||||||
settings.codemirror.indentUnit = userObject[indentKey];
|
|
||||||
delete userObject[indentKey];
|
|
||||||
}
|
|
||||||
if (typeof(userObject[useTabsKey]) !== "undefined") {
|
|
||||||
settings.codemirror = settings.codemirror || {};
|
|
||||||
settings.codemirror.indentWithTabs = userObject[useTabsKey];
|
|
||||||
delete userObject[useTabsKey];
|
|
||||||
}
|
}
|
||||||
if (typeof(userObject[drawer]) !== "undefined") {
|
}).nThen(function () {
|
||||||
settings.toolbar = settings.toolbar || {};
|
// Migration 2: global attributes from root to 'settings' subobjects
|
||||||
settings.toolbar['userlist-drawer'] = userObject[drawer];
|
var migrateAttributes = function () {
|
||||||
delete userObject[drawer];
|
var drawer = 'cryptpad.userlist-drawer';
|
||||||
|
var polls = 'cryptpad.hide_poll_text';
|
||||||
|
var indentKey = 'cryptpad.indentUnit';
|
||||||
|
var useTabsKey = 'cryptpad.indentWithTabs';
|
||||||
|
var settings = userObject.settings = userObject.settings || {};
|
||||||
|
if (typeof(userObject[indentKey]) !== "undefined") {
|
||||||
|
settings.codemirror = settings.codemirror || {};
|
||||||
|
settings.codemirror.indentUnit = userObject[indentKey];
|
||||||
|
delete userObject[indentKey];
|
||||||
|
}
|
||||||
|
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 (typeof(userObject[polls]) !== "undefined") {
|
||||||
|
settings.poll = settings.poll || {};
|
||||||
|
settings.poll['hide-text'] = userObject[polls];
|
||||||
|
delete userObject[polls];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (version < 2) {
|
||||||
|
migrateAttributes();
|
||||||
|
Feedback.send('Migrate-2', true);
|
||||||
|
userObject.version = version = 2;
|
||||||
}
|
}
|
||||||
if (typeof(userObject[polls]) !== "undefined") {
|
}).nThen(function () {
|
||||||
settings.poll = settings.poll || {};
|
// Migration 3: language from localStorage to settings
|
||||||
settings.poll['hide-text'] = userObject[polls];
|
var migrateLanguage = function () {
|
||||||
delete userObject[polls];
|
if (!localStorage.CRYPTPAD_LANG) { return; }
|
||||||
|
var l = localStorage.CRYPTPAD_LANG;
|
||||||
|
userObject.settings.language = l;
|
||||||
|
};
|
||||||
|
if (version < 3) {
|
||||||
|
migrateLanguage();
|
||||||
|
Feedback.send('Migrate-3', true);
|
||||||
|
userObject.version = version = 3;
|
||||||
}
|
}
|
||||||
};
|
}).nThen(function () {
|
||||||
if (version < 2) {
|
// Migration 4: allowUserFeedback to settings
|
||||||
migrateAttributes();
|
var migrateFeedback = function () {
|
||||||
Feedback.send('Migrate-2', true);
|
var settings = userObject.settings = userObject.settings || {};
|
||||||
userObject.version = version = 2;
|
if (typeof(userObject['allowUserFeedback']) !== "undefined") {
|
||||||
}
|
settings.general = settings.general || {};
|
||||||
|
settings.general.allowUserFeedback = userObject['allowUserFeedback'];
|
||||||
|
delete userObject['allowUserFeedback'];
|
||||||
|
}
|
||||||
// Migration 3: language from localStorage to settings
|
};
|
||||||
var migrateLanguage = function () {
|
if (version < 4) {
|
||||||
if (!localStorage.CRYPTPAD_LANG) { return; }
|
migrateFeedback();
|
||||||
var l = localStorage.CRYPTPAD_LANG;
|
Feedback.send('Migrate-4', true);
|
||||||
userObject.settings.language = l;
|
userObject.version = version = 4;
|
||||||
};
|
|
||||||
if (version < 3) {
|
|
||||||
migrateLanguage();
|
|
||||||
Feedback.send('Migrate-3', true);
|
|
||||||
userObject.version = version = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Migration 4: allowUserFeedback to settings
|
|
||||||
var migrateFeedback = function () {
|
|
||||||
var settings = userObject.settings = userObject.settings || {};
|
|
||||||
if (typeof(userObject['allowUserFeedback']) !== "undefined") {
|
|
||||||
settings.general = settings.general || {};
|
|
||||||
settings.general.allowUserFeedback = userObject['allowUserFeedback'];
|
|
||||||
delete userObject['allowUserFeedback'];
|
|
||||||
}
|
}
|
||||||
};
|
}).nThen(function () {
|
||||||
if (version < 4) {
|
// Migration 5: dates to Number
|
||||||
migrateFeedback();
|
var migrateDates = function () {
|
||||||
Feedback.send('Migrate-4', true);
|
var data = userObject.drive && userObject.drive.filesData;
|
||||||
userObject.version = version = 4;
|
if (data) {
|
||||||
}
|
for (var id in data) {
|
||||||
|
if (typeof data[id].ctime !== "number") {
|
||||||
|
data[id].ctime = +new Date(data[id].ctime);
|
||||||
|
}
|
||||||
// Migration 5: dates to Number
|
if (typeof data[id].atime !== "number") {
|
||||||
var migrateDates = function () {
|
data[id].atime = +new Date(data[id].atime);
|
||||||
var data = userObject.drive && userObject.drive.filesData;
|
}
|
||||||
if (data) {
|
|
||||||
for (var id in data) {
|
|
||||||
if (typeof data[id].ctime !== "number") {
|
|
||||||
data[id].ctime = +new Date(data[id].ctime);
|
|
||||||
}
|
|
||||||
if (typeof data[id].atime !== "number") {
|
|
||||||
data[id].atime = +new Date(data[id].atime);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
if (version < 5) {
|
||||||
|
migrateDates();
|
||||||
|
Feedback.send('Migrate-5', true);
|
||||||
|
userObject.version = version = 5;
|
||||||
|
}
|
||||||
|
}).nThen(function (waitFor) {
|
||||||
|
var addChannelId = function () {
|
||||||
|
var data = userObject.drive.filesData;
|
||||||
|
var el, parsed;
|
||||||
|
var n = nThen(function () {});
|
||||||
|
var padsLength = Object.keys(data).length;
|
||||||
|
Object.keys(data).forEach(function (k, i) {
|
||||||
|
n = n.nThen(function (w) {
|
||||||
|
setTimeout(w(function () {
|
||||||
|
el = data[k];
|
||||||
|
parsed = Hash.parsePadUrl(el.href);
|
||||||
|
if (!el.href) { return; }
|
||||||
|
if (!el.channel) {
|
||||||
|
if (parsed.hashData && parsed.hashData.type === "file") {
|
||||||
|
// PASSWORD_FILES
|
||||||
|
el.channel = Util.base64ToHex(parsed.hashData.channel);
|
||||||
|
} else {
|
||||||
|
var secret = Hash.getSecrets(parsed.type, parsed.hash, el.password);
|
||||||
|
el.channel = secret.channel;
|
||||||
|
}
|
||||||
|
progress(6, Math.round(100*i/padsLength));
|
||||||
|
console.log('Adding missing channel in filesData ', el.channel);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
n.nThen(waitFor());
|
||||||
|
};
|
||||||
|
if (version < 6) {
|
||||||
|
addChannelId();
|
||||||
|
Feedback.send('Migrate-6', true);
|
||||||
|
userObject.version = version = 6;
|
||||||
}
|
}
|
||||||
};
|
/*}).nThen(function (waitFor) {
|
||||||
if (version < 5) {
|
// Test progress bar in the loading screen
|
||||||
migrateDates();
|
var i = 0;
|
||||||
Feedback.send('Migrate-5', true);
|
var w = waitFor();
|
||||||
userObject.version = version = 5;
|
var it = setInterval(function () {
|
||||||
}
|
i += 5;
|
||||||
|
if (i >= 100) { w(); clearInterval(it); i = 100;}
|
||||||
|
progress(0, i);
|
||||||
|
}, 500);
|
||||||
|
progress(0, 0);*/
|
||||||
|
}).nThen(function () {
|
||||||
|
cb();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue