|
1 | 1 | <script setup lang="ts"> |
2 | | -import { computed, onMounted, ref, watch } from 'vue'; |
| 2 | +import { computed } from 'vue'; |
3 | 3 | import type { |
4 | 4 | CreateClientBody, |
5 | 5 | CreateProjectBody, |
@@ -38,8 +38,6 @@ const props = defineProps<{ |
38 | 38 | canCreateProject: boolean; |
39 | 39 | }>(); |
40 | 40 |
|
41 | | -const maxVisibleGroups = ref(7); // Start with 10 day groups, then show all |
42 | | -
|
43 | 41 | const groupedTimeEntries = computed(() => { |
44 | 42 | const groupedEntriesByDay: Record<string, TimeEntry[]> = {}; |
45 | 43 | for (const entry of props.timeEntries) { |
@@ -137,43 +135,11 @@ function unselectAllTimeEntries(value: TimeEntriesGroupedByType[]) { |
137 | 135 | ); |
138 | 136 | }); |
139 | 137 | } |
140 | | -
|
141 | | -const visibleGroupedEntries = computed(() => { |
142 | | - const allGroups = Object.entries(groupedTimeEntries.value); |
143 | | - return Object.fromEntries(allGroups.slice(0, maxVisibleGroups.value)); |
144 | | -}); |
145 | | -
|
146 | | -const totalGroups = computed(() => Object.keys(groupedTimeEntries.value).length); |
147 | | -
|
148 | | -function startProgressiveLoading() { |
149 | | - const loadMoreGroups = () => { |
150 | | - if (maxVisibleGroups.value < totalGroups.value) { |
151 | | - maxVisibleGroups.value = Math.min(maxVisibleGroups.value + 5, totalGroups.value); |
152 | | -
|
153 | | - if (maxVisibleGroups.value < totalGroups.value) { |
154 | | - requestIdleCallback(loadMoreGroups); |
155 | | - } |
156 | | - } |
157 | | - }; |
158 | | -
|
159 | | - requestIdleCallback(loadMoreGroups); |
160 | | -} |
161 | | -
|
162 | | -// Watch for changes to totalGroups and adjust maxVisibleGroups accordingly |
163 | | -watch(totalGroups, (newTotal, oldTotal) => { |
164 | | - if (newTotal !== oldTotal) { |
165 | | - maxVisibleGroups.value = newTotal; |
166 | | - } |
167 | | -}); |
168 | | -
|
169 | | -onMounted(() => { |
170 | | - startProgressiveLoading(); |
171 | | -}); |
172 | 138 | </script> |
173 | 139 |
|
174 | 140 | <template> |
175 | 141 | <div class="@container"> |
176 | | - <div v-for="(value, key) in visibleGroupedEntries" :key="key"> |
| 142 | + <div v-for="(value, key) in groupedTimeEntries" :key="key"> |
177 | 143 | <TimeEntryRowHeading |
178 | 144 | :date="String(key)" |
179 | 145 | :duration="sumDuration(value)" |
|
0 commit comments