From 974e4826c5f76d309e6a3e7b91ab7ce6eb6a1244 Mon Sep 17 00:00:00 2001 From: Adrien Hamraoui Date: Fri, 15 Sep 2023 16:41:40 +0200 Subject: [PATCH 1/2] fix(dalec_fetch_content): copy dataset content to avoid conflicts The previous code was using a reference to the dataset attribute of a DOM element. When we updated channelObjects with an array, channelObjects were cast to a string by the browser leading to errors when channelObjects contained a string with more than a character. Eg : channelObjects = ["499"] led to channelObjects = "4" --- dalec/static/dalec/js/main.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/dalec/static/dalec/js/main.js b/dalec/static/dalec/js/main.js index ca4c0ee..c5a2b02 100644 --- a/dalec/static/dalec/js/main.js +++ b/dalec/static/dalec/js/main.js @@ -1,13 +1,18 @@ function dalec_fetch_content(container){ - const data = container.dataset ; + const [ orderedBy, url ] = [ + container.dataset.orderedBy, + container.dataset.url + ]; + let channelObjects = container.dataset.channelObjects; + container.classList.add("dalec-loading"); - if (data.channelObjects !== undefined){ - data.channelObjects = JSON.parse(data.channelObjects) + if (channelObjects !== undefined){ + channelObjects = JSON.parse(channelObjects) } fetch( - data.url, + url, { method: "POST", headers: { @@ -16,13 +21,13 @@ function dalec_fetch_content(container){ }, // cache: "no-cache", body: JSON.stringify( - {"channelObjects": data.channelObjects, "orderedBy": data.orderedBy} + {"channelObjects": channelObjects, "orderedBy": orderedBy} ), keepalive: true, } ).then(function(response){ if (!response.ok) { - console.error(`HTTP error ${response.status} while fetching ${data.url}`); + console.error(`HTTP error ${response.status} while fetching ${url}`); return ; } if (response.status === 204) { From 014848b40bbdae6eaa51464da278ee2f728ff8da Mon Sep 17 00:00:00 2001 From: Adrien Hamraoui Date: Tue, 19 Sep 2023 15:10:59 +0200 Subject: [PATCH 2/2] chore: add me to authors --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 2d2c1a2..1184569 100644 --- a/AUTHORS +++ b/AUTHORS @@ -3,3 +3,4 @@ Federation Open Space Makers Dylann CORDEL Samuel WEBER +Adrien HAMRAOUI \ No newline at end of file