Fix history mode UI

pull/1/head
yflory 7 years ago
parent 76bc82ac13
commit 6d8693ff8c

@ -37,6 +37,7 @@
line-height: 25px; line-height: 25px;
width: 100%; width: 100%;
text-align: center; text-align: center;
color: black;
} }
.cp-toolbar-history-goto { .cp-toolbar-history-goto {
display: inline-block; display: inline-block;

@ -584,7 +584,9 @@ define([
onRemote: onRemote, onRemote: onRemote,
setHistory: setHistoryMode, setHistory: setHistoryMode,
applyVal: function (val) { applyVal: function (val) {
contentUpdate(JSON.parse(val) || ["BODY",{},[]]); contentUpdate(JSON.parse(val) || ["BODY",{},[]], function (h) {
return h;
});
}, },
$toolbar: $(toolbarContainer) $toolbar: $(toolbarContainer)
}; };

@ -79,7 +79,7 @@ define([
isComplete = data.isFull; isComplete = data.isFull;
Array.prototype.unshift.apply(allMessages, data.messages); // Destructive concat Array.prototype.unshift.apply(allMessages, data.messages); // Destructive concat
fillChainPad(realtime, allMessages); fillChainPad(realtime, allMessages);
cb (null, realtime); cb (null, realtime, data.isFull);
}); });
}; };
@ -142,7 +142,8 @@ define([
loading = true; loading = true;
$loadMore.removeClass('fa fa-ellipsis-h') $loadMore.removeClass('fa fa-ellipsis-h')
.append($('<span>', {'class': 'fa fa-refresh fa-spin fa-3x fa-fw'})); .append($('<span>', {'class': 'fa fa-refresh fa-spin fa-3x fa-fw'}));
loadMoreHistory(config, common, function (err, newRt) {
loadMoreHistory(config, common, function (err, newRt, isFull) {
if (err === 'EFULL') { if (err === 'EFULL') {
$loadMore.off('click').hide(); $loadMore.off('click').hide();
get(c); get(c);
@ -154,6 +155,10 @@ define([
update(newRt); update(newRt);
$loadMore.addClass('fa fa-ellipsis-h').html(''); $loadMore.addClass('fa fa-ellipsis-h').html('');
get(c); get(c);
if (isFull) {
$loadMore.off('click').hide();
$version.show();
}
if (cb) { cb(); } if (cb) { cb(); }
}); });
}; };
@ -181,7 +186,7 @@ define([
$hist.find('.cp-toolbar-history-fast-next').css('visibility', 'hidden'); $hist.find('.cp-toolbar-history-fast-next').css('visibility', 'hidden');
} }
var $pos = $hist.find('.cp-toolbar-history-pos'); var $pos = $hist.find('.cp-toolbar-history-pos');
var p = 100 * (1 - (-c / (states.length-1))); var p = 100 * (1 - (-c / (states.length-2)));
$pos.css('margin-left', p+'%'); $pos.css('margin-left', p+'%');
// Display the version when the full history is loaded // Display the version when the full history is loaded
@ -317,13 +322,17 @@ define([
}; };
// Load all the history messages into a new chainpad object // Load all the history messages into a new chainpad object
loadMoreHistory(config, common, function (err, newRt) { loadMoreHistory(config, common, function (err, newRt, isFull) {
History.readOnly = common.getMetadataMgr().getPrivateData().readOnly; History.readOnly = common.getMetadataMgr().getPrivateData().readOnly;
History.loading = false; History.loading = false;
if (err) { throw new Error(err); } if (err) { throw new Error(err); }
update(newRt); update(newRt);
c = states.length - 1; c = states.length - 1;
display(); display();
if (isFull) {
$loadMore.off('click').hide();
$version.show();
}
}); });
}; };

Loading…
Cancel
Save