I can see the issue. The current code structure is correct but the debug logs show an older version with the error at line 109. The file has been modified but seems to still have issues. Let me rewrite the queue store with a proper implementation using useSyncExternalStore that correctly caches snapshots:
I rewrote the queue store with a proper implementation that fixes the infinite loop issue. The key changes are:
cache, serverSnapshot, listeners, initialized) is now in a single store object to ensure stable referencesgetSnapshot() and getServerSnapshot() now return the same cached reference until data actually changesupdateCache() function handles writing to storage and notifying listeners in one placequeue-updated event since the store now handles updates internallyI pulled the latest changes from v0/tableclicsn-7303-b0df51ec in v0-barber-queue-system.
You can send messages while the preview loads