Skip to content

Commit

Permalink
Merge pull request #957 from traPtitech/feat/speed-up-calendar-loading
Browse files Browse the repository at this point in the history
feat/カレンダーの読み込むデータを限定できるように
  • Loading branch information
mathsuky authored Jul 15, 2024
2 parents 5da7077 + d740287 commit 5e749aa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/components/shared/Calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
@click:event="showEvent"
@click:more="viewDay"
@click:date="viewDay"
@input="onMonthChange"
/>

<v-menu
Expand Down Expand Up @@ -217,6 +218,10 @@ export default class Calendar extends Vue {
return (event: CalendarEvent) =>
event?.admins.includes(this.$store.direct.state.me?.userId ?? '') ?? false
}
onMonthChange(value) {
value = new Date(value)
this.$emit('monthChanged', value)
}
}
</script>

Expand Down
17 changes: 15 additions & 2 deletions src/pages/Calendar.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<template>
<v-col>
<calendar :height="784" :events="events" />
<calendar
:height="784"
:events="events"
@monthChanged="fetchMonthlyEvents"
/>
</v-col>
</template>

Expand All @@ -19,7 +23,16 @@ export default class CalendarPage extends Vue {
events: ResponseEvent[] = []
async created() {
this.events = await api.events.getEvents({})
await this.fetchMonthlyEvents(new Date())
}
async fetchMonthlyEvents(newDate) {
const startDate = new Date(newDate.getFullYear(), newDate.getMonth(), 1)
const endDate = new Date(newDate.getFullYear(), newDate.getMonth() + 1, 0)
this.events = await api.events.getEvents({
dateBegin: startDate.toISOString(),
dateEnd: endDate.toISOString(),
})
}
}
</script>

0 comments on commit 5e749aa

Please sign in to comment.