From acd7d9654ded6925cb1151aafa5084344cb2c896 Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 2 Nov 2022 14:58:29 +0100 Subject: [PATCH 1/5] Fix calendar issues --- www/calendar/inner.js | 1 - www/calendar/main.js | 4 +++- www/common/outer/calendar.js | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/www/calendar/inner.js b/www/calendar/inner.js index 7a187b434..917bbed00 100644 --- a/www/calendar/inner.js +++ b/www/calendar/inner.js @@ -124,7 +124,6 @@ define([ }; var getDateLanguage = function () { - console.error(Messages._languageUsed); try { new Date().toLocaleDateString(Messages._languageUsed, { weekday: 'long' }); return Messages._languageUsed; diff --git a/www/calendar/main.js b/www/calendar/main.js index 6f8e362f7..5858729ee 100644 --- a/www/calendar/main.js +++ b/www/calendar/main.js @@ -21,10 +21,12 @@ define([ meta.calendarOpts = Utils.Hash.decodeDataOptions(parsed.hashData.newPadOpts); } } - meta.calendarHash = Boolean(window.location.hash); + meta.calendarHash = hash; }; SFCommonO.start({ addData: addData, + hash: hash, + href: href, noRealtime: true, cache: true, }); diff --git a/www/common/outer/calendar.js b/www/common/outer/calendar.js index bc908c2c8..c09208110 100644 --- a/www/common/outer/calendar.js +++ b/www/common/outer/calendar.js @@ -913,14 +913,14 @@ define([ cleanKeys(update.one); } - if (changes.start && (!type.which || type.which === "all")) { + if (changes.start && update && (!type.which || type.which === "all")) { var diff = changes.start - ev.start; var newOne = {}; var newFrom = {}; - Object.keys(update.one).forEach(function (time) { + Object.keys(update.one || {}).forEach(function (time) { newOne[Number(time)+diff] = update.one[time]; }); - Object.keys(update.from).forEach(function (time) { + Object.keys(update.from || {}).forEach(function (time) { newFrom[Number(time)+diff] = update.from[time]; }); update.one = newOne; From 15d9a9c703775acaf07c90787733d0ef0970618f Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 9 Nov 2022 16:39:57 +0100 Subject: [PATCH 2/5] Fix middle click in drive 'New' menu --- www/common/drive-ui.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index 475b192e1..823f1b817 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -2945,7 +2945,8 @@ define([ $block.find('a.cp-app-drive-new-link, li.cp-app-drive-new-link').click(showLinkModal); } $block.find('a.cp-app-drive-new-doc, li.cp-app-drive-new-doc') - .click(function () { + .on('click auxclick', function (e) { + e.preventDefault(); var type = $(this).attr('data-type') || 'pad'; var path = manager.isPathIn(currentPath, [TRASH]) ? '' : currentPath; openIn(type, path, APP.team); @@ -3040,7 +3041,7 @@ define([ }; if (obj.type) { newObj.attributes['data-type'] = obj.type; - newObj.attributes['href'] = '#'; + newObj.attributes['href'] = APP.origin + Hash.hashToHref('', obj.type); } return newObj; }); From d03d06e3c27781152441bb8f0682e13a56bb7ac9 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 5 Dec 2022 13:54:38 +0100 Subject: [PATCH 3/5] Fix transfer ownership before storing a pad in the drive --- www/common/inner/access.js | 14 ++------------ www/common/inner/common-modal.js | 12 +++++++----- www/common/inner/properties.js | 24 +++++++++++------------- www/common/sframe-common-outer.js | 2 +- 4 files changed, 21 insertions(+), 31 deletions(-) diff --git a/www/common/inner/access.js b/www/common/inner/access.js index 6cbc8633f..597937fd3 100644 --- a/www/common/inner/access.js +++ b/www/common/inner/access.js @@ -335,11 +335,6 @@ define([ } }).nThen(function (waitFor) { var href = data.href; - var hashes = priv.hashes || {}; - var bestHash = hashes.editHash || hashes.viewHash || hashes.fileHash; - if (data.fakeHref) { - href = Hash.hashToHref(bestHash, priv.app); - } sel.forEach(function (el) { var curve = $(el).attr('data-curve'); if (curve === user.curvePublic) { return; } @@ -928,12 +923,7 @@ define([ } var href = data.href; - var hashes = priv.hashes || {}; - var bestHash = hashes.editHash || hashes.viewHash || hashes.fileHash; - if (data.fakeHref) { - href = Hash.hashToHref(bestHash, priv.app); - } - var isNotStored = Boolean(data.fakeHref); + var isNotStored = Boolean(data.isNotStored); sframeChan.query(q, { teamId: typeof(owned) !== "boolean" ? owned : undefined, href: href, @@ -1055,7 +1045,7 @@ define([ var owned = Modal.isOwned(Env, data); // Request edit access - if (common.isLoggedIn() && ((data.roHref && !data.href) || data.fakeHref) && !owned && !opts.calendar && priv.app !== 'form') { + if (common.isLoggedIn() && data.roHref && !owned && !opts.calendar && priv.app !== 'form') { var requestButton = h('button.btn.btn-secondary.no-margin.cp-access-margin-right', Messages.requestEdit_button); var requestBlock = h('p', requestButton); diff --git a/www/common/inner/common-modal.js b/www/common/inner/common-modal.js index 6d34747e2..2b6b874cf 100644 --- a/www/common/inner/common-modal.js +++ b/www/common/inner/common-modal.js @@ -42,11 +42,13 @@ define([ if (err || !val) { if (opts.access) { data.password = priv.password; - // Access modal and the pad is not stored: we're not an owner - // so we don't need the correct href, just the type - var h = Hash.createRandomHash(priv.app, priv.password); - data.fakeHref = true; - data.href = base + priv.pathname + '#' + h; + // Access modal and the pad is not stored: get the hashes from outer + var hashes = priv.hashes || {}; + data.href = Hash.hashToHref(hashes.editHash || hashes.fileHash, priv.app); + if (hashes.viewHash) { + data.roHref = Hash.hashToHref(hashes.viewHash, priv.app); + } + data.isNotStored = true; } else { waitFor.abort(); return void cb(err || 'EEMPTY'); diff --git a/www/common/inner/properties.js b/www/common/inner/properties.js index 0c5a05959..1fdf3e69f 100644 --- a/www/common/inner/properties.js +++ b/www/common/inner/properties.js @@ -37,20 +37,18 @@ define([ })); } - if (!data.fakeHref) { - if (data.href) { - $('