Feature: PocketBase Realtime-Subscription — Dashboard aktualisiert sofort nach Speichern
This commit is contained in:
parent
c8b187047a
commit
be22dde08f
1 changed files with 14 additions and 1 deletions
|
|
@ -38,8 +38,21 @@
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (!browser) return;
|
if (!browser) return;
|
||||||
fetchLiveData();
|
fetchLiveData();
|
||||||
|
|
||||||
|
// Realtime: sofort aktualisieren wenn neuer Eintrag gespeichert wird
|
||||||
|
pb.collection('check_logs').subscribe('*', (e) => {
|
||||||
|
if (e.action === 'create' && e.record?.tenant === DEMO_TENANT) {
|
||||||
|
fetchLiveData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fallback-Polling alle 30s
|
||||||
const iv = setInterval(fetchLiveData, 30_000);
|
const iv = setInterval(fetchLiveData, 30_000);
|
||||||
return () => clearInterval(iv);
|
|
||||||
|
return () => {
|
||||||
|
pb.collection('check_logs').unsubscribe('*');
|
||||||
|
clearInterval(iv);
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
function formatTime(iso: string) {
|
function formatTime(iso: string) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue