Fix subscription in the store

We are back to having instant data
This commit is contained in:
Eli Ribble 2026-03-22 07:57:55 +00:00
parent 6cd5821e5f
commit 674801c8b2
No known key found for this signature in database
3 changed files with 14 additions and 3 deletions

View file

@ -2,7 +2,7 @@ import { createApp } from "vue";
import { createPinia } from "pinia";
import App from "./App.vue";
import router from "./router";
import { SSEManager } from "./sse-manager";
import { SSEManager } from "./SSEManager";
//import { SetupSidebar } from "./sidebar";
import "maplibre-gl/dist/maplibre-gl.css";
@ -22,7 +22,11 @@ window.SSEManager = SSEManager;
document.addEventListener("DOMContentLoaded", () => {
SSEManager.connect("/api/events");
//SetupSidebar();
SSEManager.subscribe("*", (e) => {
if (e.type != "heartbeat") {
console.log("SSE", e);
}
});
});
document.addEventListener("init", () => {
const user = {

View file

@ -1,7 +1,8 @@
import { defineStore } from "pinia";
import { ref, computed } from "vue";
import { useUserStore } from "./user";
import { Communication } from "../types";
import { SSEManager } from "../SSEManager";
import { useUserStore } from "./user";
export const useCommunicationStore = defineStore("communication", () => {
// State
@ -9,6 +10,12 @@ export const useCommunicationStore = defineStore("communication", () => {
const loading = ref(false);
const error = ref(null);
// Subscription
SSEManager.subscribe("*", (e) => {
if (e.resource.startsWith("rmo")) {
fetchAll();
}
});
// Actions
async function fetchAll() {
const userStore = useUserStore();