mirror of
https://github.com/unraid/api.git
synced 2026-01-06 08:39:54 -06:00
fix(notifications): add onResult handler to update online status based on notification data
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user