nodebb-plugin-onekite-calendar 2.0.37 → 2.0.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -326,6 +326,7 @@ async function handler(req, res, next) {
326
326
  itemNames: (Array.isArray(r.itemNames) ? r.itemNames : (r.itemName ? [r.itemName] : [])),
327
327
  dateRange: `Du ${formatFR(r.start)} au ${formatFR(r.end)}`,
328
328
  paymentReceiptUrl: r.paymentReceiptUrl || '',
329
+ pickupTime: r.pickupTime || '',
329
330
  pickupAddress: r.pickupAddress || '',
330
331
  mapUrl,
331
332
  });
package/lib/widgets.js CHANGED
@@ -271,10 +271,31 @@ widgets.renderTwoWeeksWidget = async function (data) {
271
271
  wrap.appendChild(dot);
272
272
  return { domNodes: [wrap] };
273
273
  },
274
+ // IMPORTANT: disable HTTP caching here.
275
+ // Some NodeBB setups add ETag/304 on API routes; fetch(...).json() will
276
+ // then fail because 304 responses have no body, which prevents the widget
277
+ // from updating on refetchEvents(). We add a cache-buster and request
278
+ // no-store to guarantee a fresh JSON payload.
274
279
  events: function(info, successCallback, failureCallback) {
275
- const qs = new URLSearchParams({ start: info.startStr, end: info.endStr, widget: '1' });
276
- fetch(eventsEndpoint + '?' + qs.toString(), { credentials: 'same-origin' })
277
- .then((r) => r.json())
280
+ const qs = new URLSearchParams({
281
+ start: info.startStr,
282
+ end: info.endStr,
283
+ widget: '1',
284
+ _: String(Date.now()),
285
+ });
286
+ fetch(eventsEndpoint + '?' + qs.toString(), {
287
+ credentials: 'same-origin',
288
+ cache: 'no-store',
289
+ headers: { 'Cache-Control': 'no-cache' },
290
+ })
291
+ .then((r) => {
292
+ if (!r.ok) {
293
+ const err = new Error(String(r.status || 'fetch_failed'));
294
+ err.status = r.status;
295
+ throw err;
296
+ }
297
+ return r.json();
298
+ })
278
299
  .then((json) => successCallback(json || []))
279
300
  .catch((e) => failureCallback(e));
280
301
  },
@@ -405,6 +426,22 @@ dateClick: function() { window.location.href = calUrl; },
405
426
  }
406
427
  } catch (e) {}
407
428
 
429
+ // Fallback refresh: in case sockets are unavailable or blocked by proxies,
430
+ // refetch periodically and when the tab becomes visible.
431
+ try {
432
+ window.__oneKiteWidgetIntervals = window.__oneKiteWidgetIntervals || {};
433
+ if (!window.__oneKiteWidgetIntervals[containerId]) {
434
+ window.__oneKiteWidgetIntervals[containerId] = setInterval(() => {
435
+ try { calendar.refetchEvents(); } catch (e) {}
436
+ }, 60000);
437
+ }
438
+ document.addEventListener('visibilitychange', () => {
439
+ try {
440
+ if (!document.hidden) calendar.refetchEvents();
441
+ } catch (e) {}
442
+ }, { passive: true });
443
+ } catch (e) {}
444
+
408
445
  // Mobile swipe (left/right) to navigate weeks
409
446
  try {
410
447
  let touchStartX = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-onekite-calendar",
3
- "version": "2.0.37",
3
+ "version": "2.0.39",
4
4
  "description": "FullCalendar-based equipment reservation workflow with admin approval & HelloAsso payment for NodeBB",
5
5
  "main": "library.js",
6
6
  "license": "MIT",
package/plugin.json CHANGED
@@ -39,5 +39,5 @@
39
39
  "acpScripts": [
40
40
  "public/admin.js"
41
41
  ],
42
- "version": "2.0.37"
42
+ "version": "2.0.39"
43
43
  }
package/public/client.js CHANGED
@@ -545,6 +545,9 @@ define('forum/calendar-onekite', ['alerts', 'bootbox', 'hooks'], function (alert
545
545
  if (!cal || typeof cal.refetchEvents !== 'function') return;
546
546
  clearTimeout(window.__onekiteRefetchTimer);
547
547
  window.__onekiteRefetchTimer = setTimeout(() => {
548
+ // Clear the in-memory JSON cache so status/color changes are fetched
549
+ // immediately (otherwise an unchanged ETag may keep stale colors).
550
+ try { invalidateEventsCache(); } catch (e) {}
548
551
  try { cal.refetchEvents(); } catch (e) {}
549
552
  }, 150);
550
553
  } catch (e) {}
@@ -19,11 +19,11 @@
19
19
  <!-- ENDIF pickupTime -->
20
20
 
21
21
  <!-- IF pickupAddress -->
22
- <p><strong>Adresse de récupération :</strong><br>{pickupAddress}</p>
22
+ <p><strong>Adresse de récupération :</strong> {pickupAddress}</p>
23
23
  <!-- ENDIF pickupAddress -->
24
24
 
25
25
  <!-- IF mapUrl -->
26
- <p style="font-size: 12px; color: #666;"><strong>Voir sur la carte :</strong> <a href="{mapUrl}">OpenStreetMap</a</p>
26
+ <p style="font-size: 12px; color: #666;"><strong>Voir sur la carte :</strong> <a href="{mapUrl}">OpenStreetMap</a></p>
27
27
  <!-- ENDIF mapUrl -->
28
28
 
29
29
  <!-- IF notes -->
@@ -15,7 +15,7 @@
15
15
  <!-- ENDIF pickupTime -->
16
16
 
17
17
  <!-- IF pickupAddress -->
18
- <p><strong>Adresse de récupération :</strong><br>{pickupAddress}</p>
18
+ <p><strong>Adresse de récupération :</strong> {pickupAddress}</p>
19
19
  <!-- ENDIF pickupAddress -->
20
20
 
21
21
  <!-- IF mapUrl -->