Store the pad to the drive when accepting ownership

pull/1/head
yflory 6 years ago
parent ed5671a548
commit d6b6b8f11f

@ -3068,6 +3068,7 @@ define([
}; };
var storePopupState = false; var storePopupState = false;
var autoStoreModal = {};
UIElements.displayStorePadPopup = function (common, data) { UIElements.displayStorePadPopup = function (common, data) {
if (storePopupState) { return; } if (storePopupState) { return; }
storePopupState = true; storePopupState = true;
@ -3087,6 +3088,8 @@ define([
var initialHide = data && data.autoStore && data.autoStore === -1; var initialHide = data && data.autoStore && data.autoStore === -1;
var modal = UI.cornerPopup(text, actions, footer, {hidden: initialHide}); var modal = UI.cornerPopup(text, actions, footer, {hidden: initialHide});
autoStoreModal[priv.channel] = modal;
$(modal.popup).find('.cp-corner-footer a').click(function (e) { $(modal.popup).find('.cp-corner-footer a').click(function (e) {
e.preventDefault(); e.preventDefault();
common.openURL('/settings/'); common.openURL('/settings/');
@ -3094,6 +3097,7 @@ define([
$(hide).click(function () { $(hide).click(function () {
UIElements.displayCrowdfunding(common); UIElements.displayCrowdfunding(common);
delete autoStoreModal[priv.channel];
modal.delete(); modal.delete();
}); });
var waitingForStoringCb = false; var waitingForStoringCb = false;
@ -3109,6 +3113,7 @@ define([
} }
return void UI.warn(Messages.autostore_error); return void UI.warn(Messages.autostore_error);
} }
delete autoStoreModal[priv.channel];
modal.delete(); modal.delete();
UIElements.displayCrowdfunding(common); UIElements.displayCrowdfunding(common);
UI.log(Messages.autostore_saved); UI.log(Messages.autostore_saved);
@ -3350,6 +3355,21 @@ define([
// Send notification to the sender // Send notification to the sender
answer(true); answer(true);
var data = JSON.parse(JSON.stringify(msg.content));
data.metadata = res;
// Add the pad to your drive
sframeChan.query('Q_ACCEPT_OWNERSHIP', data, function (err, res) {
if (err || (res && res.error)) {
return void console.error(err | res.error);
}
UI.log(Messages.saved);
if (autoStoreModal[data.channel]) {
autoStoreModal[data.channel].delete();
delete autoStoreModal[data.channel];
}
});
// Remove yourself from the pending owners // Remove yourself from the pending owners
sframeChan.query('Q_SET_PAD_METADATA', { sframeChan.query('Q_SET_PAD_METADATA', {
channel: msg.content.channel, channel: msg.content.channel,

@ -476,6 +476,21 @@ define([
}); });
}); });
sframeChan.on('Q_ACCEPT_OWNERSHIP', function (data, cb) {
var data = {
password: data.password,
href: data.href,
channel: data.channel,
title: data.title,
owners: data.metadata.owners,
expire: data.metadata.expire,
forceSave: true
};
Cryptpad.setPadTitle(data, function (err) {
cb({error: err});
});
});
sframeChan.on('Q_IMPORT_MEDIATAG', function (obj, cb) { sframeChan.on('Q_IMPORT_MEDIATAG', function (obj, cb) {
var key = obj.key; var key = obj.key;
var channel = obj.channel; var channel = obj.channel;

Loading…
Cancel
Save