Unpin old versions

pull/1/head
yflory 7 years ago
parent c4a3e98123
commit d12e5da1b7

@ -131,8 +131,6 @@ define([
noStore: true, noStore: true,
body: $('body'), body: $('body'),
onUploaded: function (ev, data) { onUploaded: function (ev, data) {
console.log('uploaded');
console.log(data);
if (!data || !data.url) { return; } if (!data || !data.url) { return; }
common.getSframeChannel().query('Q_OO_SAVE', data, function (err) { common.getSframeChannel().query('Q_OO_SAVE', data, function (err) {
if (err) { if (err) {

@ -42,6 +42,12 @@ define([
var addRpc = function (sframeChan, Cryptpad, Utils) { var addRpc = function (sframeChan, Cryptpad, Utils) {
sframeChan.on('Q_OO_SAVE', function (data, cb) { sframeChan.on('Q_OO_SAVE', function (data, cb) {
var chanId = Utils.Hash.hrefToHexChannelId(data.url); var chanId = Utils.Hash.hrefToHexChannelId(data.url);
Cryptpad.getPadAttribute('lastVersion', function (err, data) {
if (data) {
var oldChanId = Utils.Hash.hrefToHexChannelId(data);
if (oldChanId !== chanId) { Cryptpad.unpinPads([oldChanId], function () {}); }
}
});
Cryptpad.pinPads([chanId], function (e) { Cryptpad.pinPads([chanId], function (e) {
if (e) { return void cb(e); } if (e) { return void cb(e); }
Cryptpad.setPadAttribute('lastVersion', data.url, cb); Cryptpad.setPadAttribute('lastVersion', data.url, cb);

@ -115,7 +115,9 @@ define([
window.open(origin + $link.attr('href'), '_blank'); window.open(origin + $link.attr('href'), '_blank');
}); });
var title = metadata.name; var title = metadata.name;
if (!config.noStore) {
UI.log(Messages._getKey('upload_success', [title])); UI.log(Messages._getKey('upload_success', [title]));
}
common.prepareFeedback('upload')(); common.prepareFeedback('upload')();
if (config.onUploaded) { if (config.onUploaded) {

Loading…
Cancel
Save