nodebb-plugin-onekite-calendar 2.0.24 → 2.0.25

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.
package/lib/widgets.js CHANGED
@@ -370,6 +370,41 @@ dateClick: function() { window.location.href = calUrl; },
370
370
 
371
371
  calendar.render();
372
372
 
373
+ // Real-time refresh for the widget (same server events as the main calendar)
374
+ try {
375
+ // Debounce per widget instance
376
+ let tRefetch = null;
377
+ const refetch = function () {
378
+ try {
379
+ if (tRefetch) return;
380
+ tRefetch = setTimeout(() => {
381
+ tRefetch = null;
382
+ try {
383
+ calendar.refetchEvents();
384
+ } catch (e) {}
385
+ }, 200);
386
+ } catch (e) {}
387
+ };
388
+
389
+ // Register refetcher and bind socket listeners once per page
390
+ window.__oneKiteWidgetRefetchers = window.__oneKiteWidgetRefetchers || [];
391
+ window.__oneKiteWidgetRefetchers.push(refetch);
392
+
393
+ if (!window.__oneKiteWidgetSocketBound && typeof socket !== 'undefined' && socket && typeof socket.on === 'function') {
394
+ window.__oneKiteWidgetSocketBound = true;
395
+ const triggerAll = function () {
396
+ try {
397
+ const list = window.__oneKiteWidgetRefetchers || [];
398
+ for (let i = 0; i < list.length; i += 1) {
399
+ try { list[i](); } catch (e) {}
400
+ }
401
+ } catch (e) {}
402
+ };
403
+ socket.on('event:calendar-onekite.calendarUpdated', triggerAll);
404
+ socket.on('event:calendar-onekite.reservationUpdated', triggerAll);
405
+ }
406
+ } catch (e) {}
407
+
373
408
  // Mobile swipe (left/right) to navigate weeks
374
409
  try {
375
410
  let touchStartX = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-onekite-calendar",
3
- "version": "2.0.24",
3
+ "version": "2.0.25",
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.24"
42
+ "version": "2.0.25"
43
43
  }