From 0afb2c0046b55c123eafb4ab9ee77efa68d12463 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sat, 06 Jun 2026 17:15:31 +0000
Subject: [PATCH] =Starting the Favourites.js setup, converting previous Northeh stuff to new Registrar, fixing up Square.php integration to match
---
assets/js/concise/FrontendFavourites.js | 72 +++++++++++++++++++----------------
1 files changed, 39 insertions(+), 33 deletions(-)
diff --git a/assets/js/concise/FrontendFavourites.js b/assets/js/concise/FrontendFavourites.js
index 769b4aa..e016107 100644
--- a/assets/js/concise/FrontendFavourites.js
+++ b/assets/js/concise/FrontendFavourites.js
@@ -1,33 +1,38 @@
-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',
+ 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 +49,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 +182,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