From ba1e1ccf869b818f7a7a897264dfea05563a7796 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 07 Jun 2026 20:10:20 +0000
Subject: [PATCH] =Major overhaul of Integrations. Playing around with adding fields to post types through Registrar from an integrations' class file.
---
assets/js/concise/FrontendFavourites.js | 41 ++++++++++++++++++++++++-----------------
1 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/assets/js/concise/FrontendFavourites.js b/assets/js/concise/FrontendFavourites.js
index b558f5f..661bbfc 100644
--- a/assets/js/concise/FrontendFavourites.js
+++ b/assets/js/concise/FrontendFavourites.js
@@ -1,11 +1,15 @@
-class FrontendFavourites {
+class Favourites {
constructor() {
// Initialize DataStore for queue persistence
- this.store = window.jvbStore.register(
+ let store = window.jvbStore.register(
'favourites',
{
storeName: 'favourites',
+ keyPath: 'id',
endpoint: 'favourites',
+ headers: {
+ 'X-Action-Nonce': window.auth.getNonce('favourites')
+ },
indexes: [
{name: 'content', keyPath: 'content'},
{name: 'listId', keyPath: 'listId'},
@@ -13,7 +17,7 @@
TTL: 6 * 60 * 1000,
showLoading: false,
filters: {
- user: jvbSettings.currentUser,
+ user: window.auth.getUser(),
content: 'all',
order: 'desc',
orderby: 'date',
@@ -22,14 +26,16 @@
}
});
- this.listStore = window.jvbStore.register(
- 'favourites_lists',
- {
- storeName: 'lists',
- keyPath: 'listId',
- endpoint: 'favourites/lists',
- TTL: 6 * 60 * 1000,
- });
+ this.store = store.favourites;
+
+ // this.listStore = window.jvbStore.register(
+ // 'favourites_lists',
+ // {
+ // storeName: 'lists',
+ // keyPath: 'listId',
+ // endpoint: 'favourites/lists',
+ // TTL: 6 * 60 * 1000,
+ // });
this.store.subscribe((event, data) => {
switch (event) {
@@ -46,12 +52,10 @@
}
});
-
- this.store.fetch();
}
toggleFavourite(button) {
- if (!jvbSettings.currentUser) {
+ if (!window.auth.getUser()) {
window.location.href = jvbSettings.redirect + '&action=register&type=favourites';
return;
}
@@ -181,11 +185,14 @@
return this.store.get(favId) !== undefined;
}
}
+
document.addEventListener('DOMContentLoaded', function() {
window.jvbFavourites = false;
- if (jvbSettings.currentUser !== '') {
- window.jvbFavourites = new FrontendFavourites();
- }
+ window.auth.subscribe((event) => {
+ if (event === 'auth-loaded') {
+ window.jvbFavourites = new Favourites();
+ }
+ });
});
--
Gitblit v1.10.0