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 |   75 +++++++++++++++++++++----------------
 1 files changed, 42 insertions(+), 33 deletions(-)

diff --git a/assets/js/concise/FrontendFavourites.js b/assets/js/concise/FrontendFavourites.js
index 769b4aa..661bbfc 100644
--- a/assets/js/concise/FrontendFavourites.js
+++ b/assets/js/concise/FrontendFavourites.js
@@ -1,33 +1,41 @@
-class FrontendFavourites {
+class Favourites {
 	constructor() {
 		// Initialize DataStore for queue persistence
-		this.store = new window.jvbStore({
-			name: 'favourites',
-			storeName: 'favourites',
-			endpoint: 'favourites',
-			indexes: [
-				{name: 'content', keyPath: 'content'},
-				{name: 'listId', keyPath: 'listId'},
-			],
-			TTL: 86400000,
-			showLoading: false,
-			filters: {
-				user: jvbSettings.currentUser,
-				content: 'all',
-				order: 'desc',
-				orderby: 'date',
-				page: 1,
-				all: true,
-			}
-		});
+		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'},
+				],
+				TTL: 6 * 60 * 1000,
+				showLoading: false,
+				filters: {
+					user: window.auth.getUser(),
+					content: 'all',
+					order: 'desc',
+					orderby: 'date',
+					page: 1,
+					all: true,
+				}
+			});
 
-		this.listStore = new window.jvbStore({
-			name: 'favourites_lists',
-			storeName: 'lists',
-			keyPath: 'listId',
-			endpoint: 'favourites/lists',
-			TTL: 86400000,
-		})
+		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) {
@@ -44,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;
 		}
@@ -179,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