fix(notifications): add onResult handler to update online status based on notification data

This commit is contained in:
Ajit Mehrotra
2025-12-15 17:59:05 -05:00
parent c2d2fbea40
commit e817d6a317

View File

@@ -55,7 +55,7 @@ watch(props, () => {
const unraidApiStore = useUnraidApiStore();
const { offlineError } = storeToRefs(unraidApiStore);
const { result, error, loading, fetchMore, refetch, subscribeToMore } = useQuery(
const { result, error, loading, fetchMore, refetch, subscribeToMore, onResult } = useQuery(
getNotifications,
() => ({
filter: {
@@ -67,6 +67,12 @@ const { result, error, loading, fetchMore, refetch, subscribeToMore } = useQuery
})
);
onResult((res) => {
if (res.data && unraidApiStore.unraidApiStatus === 'offline') {
unraidApiStore.unraidApiStatus = 'online';
}
});
// Debounce refetch to handle mass-add scenarios efficiently.
// Increased to 500ms to ensure we capture the entire batch of events in a single refetch,
// preventing partial updates that can lead to race conditions.