Skip to content

Commit 511f891

Browse files
committed
Show progress circle while auto mode is loading
1 parent 4be9239 commit 511f891

File tree

3 files changed

+42
-2
lines changed

3 files changed

+42
-2
lines changed

src/components/schedule/auto-mode/auto-mode-button/modes/queue/Button.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<template>
22
<Component :is="menuComponent">
33
<template #activator="{ props }">
4-
<VBtn v-bind="props" variant="tonal" color="tertiary"> Auto Mode: Queue </VBtn>
4+
<VBtn v-bind="props" :loading="pulling" variant="tonal" color="tertiary">
5+
Auto Mode: Queue
6+
</VBtn>
57
</template>
68
<div>
79
<Dialog class="dialog"></Dialog>
@@ -15,9 +17,13 @@ import { useDisplay } from "vuetify";
1517
import { VBottomSheet } from "vuetify/components/VBottomSheet";
1618
import { VMenu } from "vuetify/components/VMenu";
1719
20+
import { usePulling } from "../../usePulling";
1821
import Dialog from "./Dialog.vue";
22+
1923
const { mobile } = useDisplay();
2024
const menuComponent = computed(() => (mobile.value ? VBottomSheet : VMenu));
25+
26+
const { pulling } = await usePulling();
2127
</script>
2228

2329
<style scoped>

src/components/schedule/auto-mode/auto-mode-button/modes/scheduler/Button.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<Component :is="menuComponent">
33
<template #activator="{ props }">
4-
<VBtn v-bind="props" variant="tonal" color="tertiary">
4+
<VBtn v-bind="props" :loading="pulling" variant="tonal" color="tertiary">
55
Auto Mode: Scheduler
66
</VBtn>
77
</template>
@@ -17,9 +17,13 @@ import { useDisplay } from "vuetify";
1717
import { VBottomSheet } from "vuetify/components/VBottomSheet";
1818
import { VMenu } from "vuetify/components/VMenu";
1919
20+
import { usePulling } from "../../usePulling";
2021
import Dialog from "./Dialog.vue";
22+
2123
const { mobile } = useDisplay();
2224
const menuComponent = computed(() => (mobile.value ? VBottomSheet : VMenu));
25+
26+
const { pulling } = await usePulling();
2327
</script>
2428

2529
<style scoped>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { computed } from "vue";
2+
import type { Ref } from "vue";
3+
4+
import { useSubscribeScheduleAutoModeState } from "@/api";
5+
6+
interface _UsePullingReturn {
7+
pulling: Ref<boolean>;
8+
}
9+
10+
type UsePullingReturn = _UsePullingReturn & PromiseLike<_UsePullingReturn>;
11+
12+
export function usePulling(): UsePullingReturn {
13+
const subscription = useSubscribeScheduleAutoModeState();
14+
15+
// e.g., "off", "auto_pulling", "auto_running"
16+
const state = subscription.autoModeState;
17+
18+
// true if the second part of the state is "pulling"
19+
const pulling = computed(() => state.value?.split("_")[1] === "pulling");
20+
21+
const ret = { pulling };
22+
23+
return {
24+
...ret,
25+
async then(onFulfilled, onRejected) {
26+
await subscription;
27+
return Promise.resolve(ret).then(onFulfilled, onRejected);
28+
},
29+
};
30+
}

0 commit comments

Comments
 (0)