fix: polling still running when modal open
This commit is contained in:
@@ -2,6 +2,7 @@ import type { Station } from '@/apis/domains';
|
||||
import type { NdmDeviceAlarmLogResultVO } from '@/apis/models';
|
||||
import { postNdmDeviceAlarmLogPage } from '@/apis/requests';
|
||||
import { DeviceType } from '@/enums/device-type';
|
||||
import { useQueryControlStore } from '@/stores/query-control';
|
||||
import { useStationStore } from '@/stores/station';
|
||||
import { useQuery } from '@tanstack/vue-query';
|
||||
import dayjs from 'dayjs';
|
||||
@@ -32,12 +33,16 @@ export interface LineAlarms {
|
||||
export function useLineAlarmsQuery() {
|
||||
const stationStore = useStationStore();
|
||||
const { updatedTime, stationList, onlineStationList } = storeToRefs(stationStore);
|
||||
const queryControlStore = useQueryControlStore();
|
||||
const { pollingEnabled } = storeToRefs(queryControlStore);
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['line-alarms', updatedTime],
|
||||
enabled: computed(() => onlineStationList.value.length > 0),
|
||||
enabled: computed(() => onlineStationList.value.length > 0 && pollingEnabled.value),
|
||||
placeholderData: (prev) => prev,
|
||||
queryFn: async (): Promise<LineAlarms> => {
|
||||
// console.time('useLineAlarmsQuery');
|
||||
|
||||
const lineAlarms: LineAlarms = {};
|
||||
|
||||
if (!stationList?.value) {
|
||||
@@ -96,6 +101,8 @@ export function useLineAlarmsQuery() {
|
||||
}
|
||||
}
|
||||
|
||||
// console.timeEnd('useLineAlarmsQuery');
|
||||
|
||||
return lineAlarms;
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user