Skip to content

Commit 8495268

Browse files
committed
Fix a bug in which the exception isn't shown on the main tab
1 parent a3b4341 commit 8495268

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

src/components/exception/Exception.vue

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
</template>
99

1010
<script setup lang="ts">
11-
import { ref, watch } from "vue";
11+
import { computed, watchEffect } from "vue";
12+
import { useVModel } from "@vueuse/core";
1213
1314
import { useSubscribeState } from "@/api";
1415
import { useCtrlExceptionQuery } from "@/graphql/codegen/generated";
@@ -24,36 +25,27 @@ type Emits = {
2425
const props = defineProps<Props>();
2526
const emit = defineEmits<Emits>();
2627
28+
const alert = useVModel(props, "modelValue", emit);
29+
2730
const stateSubscription = useSubscribeState();
2831
const { state } = stateSubscription;
2932
30-
const pause = ref(true);
31-
32-
const query = useCtrlExceptionQuery({ pause: pause.value });
33+
const query = useCtrlExceptionQuery({ pause: true, variables: {} });
3334
34-
watch(state, (val) => {
35-
pause.value = val !== "finished";
36-
if (!pause.value) {
37-
query.executeQuery();
35+
watchEffect(() => {
36+
if (state.value !== "finished") {
37+
alert.value = false;
38+
return;
3839
}
40+
query.executeQuery();
3941
});
4042
41-
const exception = ref(null as string | null | undefined);
42-
43-
const alert = ref(false);
44-
45-
watch(props, (val) => {
46-
alert.value = val.modelValue;
47-
});
48-
49-
watch(query.data, (val) => {
50-
alert.value = !!val?.ctrl.exception;
51-
exception.value = val?.ctrl.exception;
52-
});
43+
const exception = computed(() =>
44+
state.value !== "finished" ? null : query.data.value?.ctrl.exception
45+
);
5346
54-
watch(alert, (val) => {
55-
if (!val) exception.value = null;
56-
emit("update:modelValue", val);
47+
watchEffect(() => {
48+
alert.value = !!exception.value;
5749
});
5850
5951
await stateSubscription;

0 commit comments

Comments
 (0)