From d12e5da1b721c684543e24e81c311affafd5c539 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 29 Mar 2018 10:54:40 +0200 Subject: [PATCH] Unpin old versions --- www/common/onlyoffice/inner.js | 2 -- www/common/onlyoffice/main.js | 6 ++++++ www/common/sframe-common-file.js | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 76b4754df..c5b60a48e 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -131,8 +131,6 @@ define([ noStore: true, body: $('body'), onUploaded: function (ev, data) { - console.log('uploaded'); - console.log(data); if (!data || !data.url) { return; } common.getSframeChannel().query('Q_OO_SAVE', data, function (err) { if (err) { diff --git a/www/common/onlyoffice/main.js b/www/common/onlyoffice/main.js index fcdf6bf31..b400b1df8 100644 --- a/www/common/onlyoffice/main.js +++ b/www/common/onlyoffice/main.js @@ -42,6 +42,12 @@ define([ var addRpc = function (sframeChan, Cryptpad, Utils) { sframeChan.on('Q_OO_SAVE', function (data, cb) { 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) { if (e) { return void cb(e); } Cryptpad.setPadAttribute('lastVersion', data.url, cb); diff --git a/www/common/sframe-common-file.js b/www/common/sframe-common-file.js index ab3111ff0..e543b562d 100644 --- a/www/common/sframe-common-file.js +++ b/www/common/sframe-common-file.js @@ -115,7 +115,9 @@ define([ window.open(origin + $link.attr('href'), '_blank'); }); var title = metadata.name; - UI.log(Messages._getKey('upload_success', [title])); + if (!config.noStore) { + UI.log(Messages._getKey('upload_success', [title])); + } common.prepareFeedback('upload')(); if (config.onUploaded) {