Pin images included in the spreadsheets

This commit is contained in:
yflory
2020-01-20 18:05:31 +01:00
parent 7f4dbd3245
commit dbb726e4ce
3 changed files with 52 additions and 1 deletions

View File

@@ -88,6 +88,32 @@ define([
}, cb);
});
});
sframeChan.on('EV_OO_PIN_IMAGES', function (list) {
Cryptpad.getPadAttribute('ooImages', function (err, res) {
if (err) { return; }
if (!res || !Array.isArray(res)) { res = []; }
var toPin = [];
var toUnpin = [];
res.forEach(function (id) {
if (list.indexOf(id) === -1) {
toUnpin.push(id);
}
});
list.forEach(function (id) {
if (res.indexOf(id) === -1) {
toPin.push(id);
}
});
toPin = Utils.Util.deduplicateString(toPin);
toUnpin = Utils.Util.deduplicateString(toUnpin);
Cryptpad.pinPads(toPin, function () {});
Cryptpad.unpinPads(toUnpin, function () {});
if (!toPin.length && !toUnpin.length) { return; }
Cryptpad.setPadAttribute('ooImages', list, function (err) {
if (err) { console.error(err); }
});
});
});
sframeChan.on('Q_OO_COMMAND', function (obj, cb) {
if (obj.cmd === 'SEND_MESSAGE') {
obj.data.msg = Utils.crypto.encrypt(JSON.stringify(obj.data.msg));