mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
wip
This commit is contained in:
parent
65cab7fbad
commit
c32593e498
@ -43,8 +43,10 @@ define([
|
||||
|
||||
var fillOO = function (id, messages) {
|
||||
if (!id) { return; }
|
||||
if (ooMessages[id]) { return; }
|
||||
// if (ooMessages[id]) { return; }
|
||||
|
||||
ooMessages[id] = messages;
|
||||
|
||||
update();
|
||||
};
|
||||
|
||||
@ -105,7 +107,7 @@ define([
|
||||
if (config.debug) {
|
||||
console.log(data.messages);
|
||||
}
|
||||
|
||||
id = getId()
|
||||
fillOO(id, messages);
|
||||
loading = false;
|
||||
// $share.show();
|
||||
@ -116,6 +118,7 @@ define([
|
||||
|
||||
// We want to load a checkpoint (or initial state)
|
||||
var loadMoreOOHistory = function () {
|
||||
|
||||
if (!Array.isArray(sortedCp)) { return void console.error("Wrong type"); }
|
||||
|
||||
var cp = {};
|
||||
@ -141,7 +144,7 @@ define([
|
||||
// Next cp or last hash
|
||||
var fromHash = nextId ? hashes[nextId].hash : config.onlyoffice.lastHash;
|
||||
|
||||
msgIndex = -1;
|
||||
// msgIndex = -1;
|
||||
|
||||
showVersion();
|
||||
if (ooMessages[id]) {
|
||||
@ -167,8 +170,8 @@ define([
|
||||
});
|
||||
|
||||
var onClose = function () { config.setHistory(false); };
|
||||
var onRevert = function (msgs) {
|
||||
config.onRevert(msgs);
|
||||
var onRevert = function () {
|
||||
config.onRevert();
|
||||
};
|
||||
|
||||
config.setHistory(true);
|
||||
@ -183,7 +186,7 @@ define([
|
||||
|
||||
var getId = function () {
|
||||
var cps = sortedCp.length;
|
||||
return sortedCp[cps - cpIndex -1] || -1;
|
||||
return sortedCp[cps-1] || -1;
|
||||
};
|
||||
|
||||
update = function () {
|
||||
@ -204,13 +207,13 @@ define([
|
||||
var id = getId();
|
||||
var msgs = (ooMessages[id] || []).length;
|
||||
var v = getVersion()
|
||||
if (msgIndex >= (msgs-1) || v === '1.0') {
|
||||
if (msgIndex >= (msgs-1)) {
|
||||
$next.prop('disabled', 'disabled');
|
||||
}
|
||||
};
|
||||
|
||||
var next = function () {
|
||||
var id = -1
|
||||
var id = getId()
|
||||
if (!ooMessages[id]) { loading = false; return; }
|
||||
var msgs = ooMessages[id];
|
||||
var cp = ooCheckpoints[id];
|
||||
@ -228,16 +231,14 @@ define([
|
||||
var prev = function () {
|
||||
|
||||
var id = getId();
|
||||
var msgs = ooMessages[-1];
|
||||
var msgs = ooMessages[id];
|
||||
var cp = ooCheckpoints[id];
|
||||
var queue = msgs.slice(0, msgIndex);
|
||||
config.onPatchBack(cp, queue, newlyLoaded);
|
||||
newlyLoaded = false
|
||||
showVersion();
|
||||
|
||||
msgIndex--;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -344,7 +345,7 @@ define([
|
||||
$prev.click(function () {
|
||||
// if (loading) { return; }
|
||||
loading = true;
|
||||
// loadMoreOOHistory();
|
||||
loadMoreOOHistory();
|
||||
prev();
|
||||
update();
|
||||
});
|
||||
@ -434,8 +435,7 @@ define([
|
||||
if (!yes) { return; }
|
||||
closeUI();
|
||||
History.loading = false;
|
||||
console.log("messages2", ooMessages[-1])
|
||||
onRevert(ooMessages[-1]);
|
||||
onRevert();
|
||||
UI.log(Messages.history_restoreDone);
|
||||
});
|
||||
});
|
||||
|
||||
@ -588,7 +588,6 @@ define([
|
||||
};
|
||||
|
||||
var saveToServer = function (blob, title, msgs) {
|
||||
APP.msgs = msgs
|
||||
if (APP.cantCheckpoint) { return; } // TOO_LARGE
|
||||
var text = !blob && getContent();
|
||||
if (!text && !blob) {
|
||||
@ -1094,22 +1093,7 @@ define([
|
||||
|
||||
const getInitialChanges = function() {
|
||||
const changes = [];
|
||||
if (APP.msgs) {
|
||||
msgsFormatted = []
|
||||
APP.msgs.forEach(function(msg) {
|
||||
var parsedMsg = JSON.parse(msg.msg);
|
||||
var formattedMsg = {
|
||||
msg: parsedMsg,
|
||||
hash: msg.serverHash,
|
||||
author: msg.author,
|
||||
time: msg.time
|
||||
};
|
||||
|
||||
msgsFormatted.push(formattedMsg)
|
||||
|
||||
})
|
||||
ooChannel.queue = msgsFormatted
|
||||
}
|
||||
if (content.version > 2) {
|
||||
ooChannel.queue.forEach(function (data) {
|
||||
Array.prototype.push.apply(changes, data.msg.changes);
|
||||
@ -1120,7 +1104,6 @@ define([
|
||||
var last = ooChannel.queue.pop();
|
||||
if (last) { ooChannel.lastHash = last.hash; }
|
||||
}
|
||||
APP.msgs = false
|
||||
return changes
|
||||
|
||||
};
|
||||
@ -3185,15 +3168,13 @@ Uncaught TypeError: Cannot read property 'calculatedType' of null
|
||||
if (newlyLoaded) {
|
||||
originalHistory = ooChannel.queue
|
||||
}
|
||||
// We want to load a checkpoint:
|
||||
msgsFormatted = []
|
||||
msgs.forEach(function(msg) {
|
||||
var parsedMsg = JSON.parse(msg.msg);
|
||||
|
||||
// Create the new format2 object structure
|
||||
var formattedMsg = {
|
||||
msg: parsedMsg,
|
||||
hash: msg.serverHash, // Map serverHash to hash
|
||||
hash: msg.serverHash,
|
||||
author: msg.author,
|
||||
time: msg.time
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user