From 163c6556a02c20578594d800c1d67215fbfeab78 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 26 Jun 2020 15:38:30 +0200 Subject: [PATCH 1/4] Update atime when embedding a mediatag to a pad --- www/common/onlyoffice/inner.js | 1 + www/common/sframe-app-framework.js | 1 + www/poll/inner.js | 1 + www/secureiframe/inner.js | 1 + www/secureiframe/main.js | 9 --------- 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/www/common/onlyoffice/inner.js b/www/common/onlyoffice/inner.js index 8e43e42b1..64dbf857f 100644 --- a/www/common/onlyoffice/inner.js +++ b/www/common/onlyoffice/inner.js @@ -1150,6 +1150,7 @@ define([ APP.realtime.onSettle(function () { APP.getImageURL(name, function(url) { debug("CRYPTPAD success add " + name); + common.setPadAttribute('atime', +new Date(), null, data.href); APP.AddImageSuccessCallback({ name: name, url: url diff --git a/www/common/sframe-app-framework.js b/www/common/sframe-app-framework.js index 08509dba7..112750a55 100644 --- a/www/common/sframe-app-framework.js +++ b/www/common/sframe-app-framework.js @@ -538,6 +538,7 @@ define([ } if (!mediaTagEmbedder) { console.log('mediaTagEmbedder missing'); return; } if (data.type !== 'file') { console.log('unhandled embed type ' + data.type); return; } + common.setPadAttribute('atime', +new Date(), null, data.href); var privateDat = cpNfInner.metadataMgr.getPrivateData(); var origin = privateDat.fileHost || privateDat.origin; var src = data.src = data.src.slice(0,1) === '/' ? origin + data.src : data.src; diff --git a/www/poll/inner.js b/www/poll/inner.js index 66b3091ed..0dd4409ce 100644 --- a/www/poll/inner.js +++ b/www/poll/inner.js @@ -1205,6 +1205,7 @@ define([ }; common.openFilePicker(pickerCfg, function (data) { if (data.type === 'file' && APP.editor) { + common.setPadAttribute('atime', +new Date(), null, data.href); var mt = ''; APP.editor.replaceSelection(mt); return; diff --git a/www/secureiframe/inner.js b/www/secureiframe/inner.js index 1aa94d9cd..1d3132b37 100644 --- a/www/secureiframe/inner.js +++ b/www/secureiframe/inner.js @@ -114,6 +114,7 @@ define([ var key = Hash.encodeBase64(secret.keys.cryptKey); sframeChan.event("EV_SECURE_ACTION", { type: parsed.type, + href: data.url, src: src, name: data.name, key: key diff --git a/www/secureiframe/main.js b/www/secureiframe/main.js index 330356135..eca166592 100644 --- a/www/secureiframe/main.js +++ b/www/secureiframe/main.js @@ -144,15 +144,6 @@ define([ config.onFileUpload(sframeChan, data, cb); }); - sframeChan.on('Q_GET_FILES_LIST', function (types, cb) { - Cryptpad.getSecureFilesList(types, function (err, data) { - cb({ - error: err, - data: data - }); - }); - }); - sframeChan.on('EV_SECURE_IFRAME_CLOSE', function () { config.onClose(); }); From 74b379999e298386ecc075841d98afd38eff189c Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 26 Jun 2020 15:42:50 +0200 Subject: [PATCH 2/4] Improve error message when opening an expired pad --- www/common/sframe-common-outer.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/www/common/sframe-common-outer.js b/www/common/sframe-common-outer.js index 3fbba216d..26ffa07a2 100644 --- a/www/common/sframe-common-outer.js +++ b/www/common/sframe-common-outer.js @@ -288,7 +288,15 @@ define([ var newHref; var expire; nThen(function (w) { - if (parsed.hashData.key || !parsed.hashData.channel) { return; } + // If we're using an unsafe link, get pad attribute + if (parsed.hashData.key || !parsed.hashData.channel) { + Cryptpad.getPadAttribute('expire', w(function (err, data) { + if (err) { return; } + expire = data; + })); + return; + } + // Otherwise, get pad data from channel id var edit = parsed.hashData.mode === 'edit'; Cryptpad.getPadDataFromChannel({ channel: parsed.hashData.channel, From c04c22cbb8fd0afdf5a94694db9420720da562e4 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 26 Jun 2020 15:58:03 +0200 Subject: [PATCH 3/4] Add missing buttons to debug app --- customize.dist/src/less2/include/framework.less | 6 +++++- www/debug/app-debug.less | 2 +- www/debug/inner.js | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/customize.dist/src/less2/include/framework.less b/customize.dist/src/less2/include/framework.less index c698b91b9..7876195c1 100644 --- a/customize.dist/src/less2/include/framework.less +++ b/customize.dist/src/less2/include/framework.less @@ -19,7 +19,11 @@ @import (reference) "./forms.less"; @import (reference) "./modals-ui-elements.less"; -.framework_main(@bg-color, @warn-color, @color) { +.framework_main( + @bg-color: @colortheme_default-bg, // color of the toolbar background + @warn-color: @colortheme_default-warn, // color of the warning text in the toolbar + @color: @colortheme_default-color, // Color of the text for the toolbar +) { --LessLoader_require: LessLoader_currentFile(); // Set the HTML style for the apps which shouldn't have a body scrollbar .app-noscroll_main(); diff --git a/www/debug/app-debug.less b/www/debug/app-debug.less index 697a46612..52a19387c 100644 --- a/www/debug/app-debug.less +++ b/www/debug/app-debug.less @@ -4,7 +4,7 @@ // body &.cp-app-debug { .tokenfield_main(); - .framework_min_main(); + .framework_main(); display: flex; flex-flow: column; diff --git a/www/debug/inner.js b/www/debug/inner.js index f73e9120a..00d97c839 100644 --- a/www/debug/inner.js +++ b/www/debug/inner.js @@ -605,7 +605,7 @@ define([ Title = common.createTitle({}); var configTb = { - displayed: ['title', 'useradmin', 'spinner', 'share', 'userlist', 'newpad', 'limit'], + displayed: ['pad'], title: Title.getTitleConfig(), metadataMgr: metadataMgr, readOnly: 1, @@ -633,7 +633,7 @@ define([ }; var $hist = common.createButton('history', true, {histConfig: histConfig}); $hist.addClass('cp-hidden-if-readonly'); - toolbar.$rightside.append($hist); + toolbar.$drawer.append($hist); var $content = common.createButton(null, true, { icon: 'fa-question', @@ -642,7 +642,7 @@ define([ id: 'cp-app-debug-get-content' }); $content.click(getContent); - toolbar.$rightside.append($content); + toolbar.$drawer.append($content); }; config.onReady = function (info) { From 98cc87888e45bf46613919a20bac4925b3ff6cee Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 26 Jun 2020 16:41:13 +0200 Subject: [PATCH 4/4] Fix kanban rendering issues --- www/kanban/jkanban_cp.js | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/www/kanban/jkanban_cp.js b/www/kanban/jkanban_cp.js index 1604a1315..0e0568f16 100644 --- a/www/kanban/jkanban_cp.js +++ b/www/kanban/jkanban_cp.js @@ -1,9 +1,10 @@ define([ 'jquery', '/customize/messages.js', + '/common/common-util.js', '/common/visible.js', '/bower_components/dragula.js/dist/dragula.min.js', -], function ($, Messages, Visible, Dragula) { +], function ($, Messages, Util, Visible, Dragula) { /** * jKanban * Vanilla Javascript plugin for manage kanban boards @@ -740,7 +741,6 @@ define([ return self; }; - var todoOnVisible = function () {}; var onVisibleHandler = false; this.setBoards = function (boards) { var scroll = {}; @@ -750,15 +750,23 @@ define([ // Get horizontal scroll var $el = $(self.element); var scrollLeft = $el.scrollLeft(); - // Remove all boards - for (var i in this.options.boards.list) { - var boardkey = this.options.boards.list[i]; - scroll[boardkey] = $('.kanban-board[data-id="'+boardkey+'"] .kanban-drag').scrollTop(); - this.removeBoard(boardkey); - } + // Get existing boards list + var list = Util.clone(this.options.boards.list); + + // Update memory this.options.boards = boards; - todoOnVisible = function () { + // If the tab is not focused but a handler already exists: abort + if (!Visible.currently() && onVisibleHandler) { return; } + + var todoOnVisible = function () { + // Remove all boards + for (var i in list) { + var boardkey = list[i]; + scroll[boardkey] = $('.kanban-board[data-id="'+boardkey+'"] .kanban-drag').scrollTop(); + self.removeBoard(boardkey); + } + // Add all new boards self.addBoards(); self.options.refresh(); @@ -772,7 +780,6 @@ define([ // If the tab is not focused, redraw on focus if (!Visible.currently()) { - if (onVisibleHandler) { return; } onVisibleHandler = true; return void Visible.onChange(function (visible) { if (!visible) { return; }