mirror of
https://github.com/YouHaveTrouble/DiscipleOfLand.git
synced 2026-05-11 22:16:55 +00:00
sync the timers with sorting to avoid weird desyncs between them
This commit is contained in:
+1
-1
@@ -91,7 +91,7 @@ export default defineComponent({
|
||||
this.eorzeaTime = new EorzeaTime();
|
||||
setInterval(() => {
|
||||
this.eorzeaTime = new EorzeaTime();
|
||||
}, 500);
|
||||
}, 1000);
|
||||
|
||||
const itemData: Response | null = await fetch("/data/items.json")
|
||||
.catch((): null => {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
>
|
||||
<div class="timer">
|
||||
{{
|
||||
prettyTimer(gatheringNode.getSecondsToNextActiveTime(eorzeaTime))
|
||||
prettyTimer(secondsToNextActiveTime)
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
@@ -19,7 +19,7 @@
|
||||
Active
|
||||
<div class="countdown">
|
||||
{{
|
||||
prettyTimer(gatheringNode.getSecondsToNextInactiveTime(eorzeaTime))
|
||||
prettyTimer(secondsToNextInactiveTime)
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
@@ -69,6 +69,12 @@ import Zone from "@/entities/Zone";
|
||||
|
||||
export default defineComponent({
|
||||
name: "GatheringNode",
|
||||
data() {
|
||||
return {
|
||||
secondsToNextInactiveTime: 0 as number,
|
||||
secondsToNextActiveTime: 0 as number,
|
||||
};
|
||||
},
|
||||
props: {
|
||||
gatheringNode: {
|
||||
type: Object as PropType<Node>,
|
||||
@@ -83,13 +89,27 @@ export default defineComponent({
|
||||
required: true
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
eorzeaTime: {
|
||||
handler() {
|
||||
this.calculateTimers()
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
prettyTimer(seconds: number): string {
|
||||
const minutes = Math.floor(seconds / 60);
|
||||
const remainingSeconds = seconds % 60;
|
||||
return `${minutes}:${remainingSeconds < 10 ? '0' : ''}${remainingSeconds}`;
|
||||
},
|
||||
calculateTimers() {
|
||||
this.secondsToNextInactiveTime = this.gatheringNode.getSecondsToNextInactiveTime(this.eorzeaTime);
|
||||
this.secondsToNextActiveTime = this.gatheringNode.getSecondsToNextActiveTime(this.eorzeaTime);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.calculateTimers();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -49,9 +49,7 @@ export default defineComponent(
|
||||
}
|
||||
},
|
||||
eorzeaTime: {
|
||||
handler(newValue, oldValue) {
|
||||
if (oldValue === undefined) return;
|
||||
if (newValue?.getMinutes() === oldValue?.getMinutes()) return;
|
||||
handler() {
|
||||
this.sortListByTime();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ export default class TimeRange {
|
||||
public isWithinTimeFrame(hour: number, minute: number): boolean {
|
||||
return (
|
||||
this.from[0] < hour || this.from[0] == hour && this.from[1] <= minute)
|
||||
&& (hour < this.to[0] || hour == this.to[0] && minute <= this.to[1]
|
||||
&& (hour < this.to[0] || hour == this.to[0] && minute < this.to[1]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user