Block snapshot creation while disconnected

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

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

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

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

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

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

Loading…
Cancel
Save