Block snapshot creation while disconnected

pull/1/head
yflory 4 years ago
parent 014d968b37
commit b5f48a43e3

@ -125,8 +125,11 @@
margin-bottom: @snapshot_spacing; margin-bottom: @snapshot_spacing;
max-height: 245px; max-height: 245px;
overflow: auto; overflow: auto;
min-height: 100px;
outline: none; outline: none;
.cp-snapshot-spinner {
min-height: 90px;
text-align: center;
}
.cp-snapshot-element { .cp-snapshot-element {
display: flex; display: flex;
align-items: center; align-items: center;

@ -197,6 +197,7 @@
right: 1px; right: 1px;
top: 1px; top: 1px;
bottom: 1px; bottom: 1px;
cursor: pointer;
.cp-history-snapshot { .cp-history-snapshot {
position: absolute; position: absolute;
border: 2px solid @cryptpad_text_col; border: 2px solid @cryptpad_text_col;

@ -3314,6 +3314,7 @@ define([
Messages.snapshots_placeholder = "Snapshot title"; // XXX Messages.snapshots_placeholder = "Snapshot title"; // XXX
Messages.snapshots_open = "View"; Messages.snapshots_open = "View";
Messages.snapshots_delete = "Delete"; Messages.snapshots_delete = "Delete";
Messages.snapshots_cantMake = "Disconnected. Can't create a new snapshot now.";
UIElements.openSnapshotsModal = function (common, load, make, remove) { UIElements.openSnapshotsModal = function (common, load, make, remove) {
var modal; var modal;
var readOnly = common.getMetadataMgr().getPrivateData().readOnly; var readOnly = common.getMetadataMgr().getPrivateData().readOnly;
@ -3406,10 +3407,15 @@ define([
onClick: function () { onClick: function () {
var val = $input.val(); var val = $input.val();
if (!val) { return true; } if (!val) { return true; }
$container.html(''); $container.html('').append(h('div.cp-snapshot-spinner'));
UI.spinner($container).get().show(); var to = setTimeout(function () {
UI.spinner($container.find('div')).get().show();
});
make(val, function (err) { make(val, function (err) {
if (err) { return; } clearTimeout(to);
if (err) {
return void UI.alert(Messages.snapshots_cantMake);
}
refresh(); refresh();
}); });
return true; return true;

@ -138,6 +138,9 @@ define([
onLocal(); onLocal();
}; };
var makeSnapshot = function (title, cb) { var makeSnapshot = function (title, cb) {
if (state !== STATE.READY) {
return void cb('NOT_READY');
}
var sframeChan = common.getSframeChannel(); var sframeChan = common.getSframeChannel();
sframeChan.query("Q_GET_LAST_HASH", null, function (err, obj) { sframeChan.query("Q_GET_LAST_HASH", null, function (err, obj) {
if (err || (obj && obj.error)) { return void UI.warn(Messages.error); } if (err || (obj && obj.error)) { return void UI.warn(Messages.error); }
@ -357,6 +360,7 @@ define([
}; };
var setLastMetadata = function (md) { var setLastMetadata = function (md) {
if (!unsyncMode) { return; } if (!unsyncMode) { return; }
if (state !== STATE.READY) { return; }
var newContentStr = cpNfInner.chainpad.getAuthDoc(); var newContentStr = cpNfInner.chainpad.getAuthDoc();
var newContent = JSON.parse(newContentStr); var newContent = JSON.parse(newContentStr);
if (Array.isArray(newContent)) { if (Array.isArray(newContent)) {

@ -396,7 +396,7 @@ define([
time: block.time ? (+new Date(block.time)) : +new Date() time: block.time ? (+new Date(block.time)) : +new Date()
}; };
var sent = config.setLastMetadata(md); var sent = config.setLastMetadata(md);
if (!sent) { return void UI.warn(Messages.error); } if (!sent) { return void UI.alert(Messages.snapshots_cantMake); }
refreshBar(); refreshBar();
} catch (e) { } catch (e) {
console.error(e); console.error(e);

Loading…
Cancel
Save