From 6d8693ff8c632b0d213343a33419f93eaab617c5 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 25 Jun 2018 16:59:40 +0200 Subject: [PATCH] Fix history mode UI --- .../src/less2/include/toolbar-history.less | 1 + www/common/sframe-app-framework.js | 4 +++- www/common/sframe-common-history.js | 17 +++++++++++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/customize.dist/src/less2/include/toolbar-history.less b/customize.dist/src/less2/include/toolbar-history.less index 31da75ad1..54a3bb0a0 100644 --- a/customize.dist/src/less2/include/toolbar-history.less +++ b/customize.dist/src/less2/include/toolbar-history.less @@ -37,6 +37,7 @@ line-height: 25px; width: 100%; text-align: center; + color: black; } .cp-toolbar-history-goto { display: inline-block; diff --git a/www/common/sframe-app-framework.js b/www/common/sframe-app-framework.js index 6bd967ffe..e0b9aa1ea 100644 --- a/www/common/sframe-app-framework.js +++ b/www/common/sframe-app-framework.js @@ -584,7 +584,9 @@ define([ onRemote: onRemote, setHistory: setHistoryMode, applyVal: function (val) { - contentUpdate(JSON.parse(val) || ["BODY",{},[]]); + contentUpdate(JSON.parse(val) || ["BODY",{},[]], function (h) { + return h; + }); }, $toolbar: $(toolbarContainer) }; diff --git a/www/common/sframe-common-history.js b/www/common/sframe-common-history.js index efaa01cc1..189507676 100644 --- a/www/common/sframe-common-history.js +++ b/www/common/sframe-common-history.js @@ -79,7 +79,7 @@ define([ isComplete = data.isFull; Array.prototype.unshift.apply(allMessages, data.messages); // Destructive concat fillChainPad(realtime, allMessages); - cb (null, realtime); + cb (null, realtime, data.isFull); }); }; @@ -142,7 +142,8 @@ define([ loading = true; $loadMore.removeClass('fa fa-ellipsis-h') .append($('', {'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') { $loadMore.off('click').hide(); get(c); @@ -154,6 +155,10 @@ define([ update(newRt); $loadMore.addClass('fa fa-ellipsis-h').html(''); get(c); + if (isFull) { + $loadMore.off('click').hide(); + $version.show(); + } if (cb) { cb(); } }); }; @@ -181,7 +186,7 @@ define([ $hist.find('.cp-toolbar-history-fast-next').css('visibility', 'hidden'); } 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+'%'); // Display the version when the full history is loaded @@ -317,13 +322,17 @@ define([ }; // 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.loading = false; if (err) { throw new Error(err); } update(newRt); c = states.length - 1; display(); + if (isFull) { + $loadMore.off('click').hide(); + $version.show(); + } }); };