Skip to content

Commit 3235dca

Browse files
committed
fix(loading): increase loading debounce and adjust date loader
1 parent a5345dc commit 3235dca

File tree

4 files changed

+37
-21
lines changed

4 files changed

+37
-21
lines changed

src/components/common/list/ListItem.vue

+32-17
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,19 @@ const onClick = () => emit('onItemClick', { item: item?.value });
203203
size="small"
204204
:theme-overrides="{ gapSmall: '0.25rem' }"
205205
>
206-
<template v-if="date && !noHead && !loading">
207-
<NTime class="month" :time="date" format="MMM" />
208-
<NTime class="day" :time="date" format="dd" />
209-
<NTime class="week" :time="date" format="eee" />
210-
<NTime v-if="!sameYear" class="year" :time="date" format="yyyy" />
211-
</template>
212-
<template v-else-if="loading">
213-
<NSkeleton class="loading month" text round />
214-
<NSkeleton class="loading day" text round />
215-
<NSkeleton class="loading week" text round />
216-
</template>
206+
<Transition v-if="!noHead && date" name="fade">
207+
<div v-if="loading" class="column">
208+
<NSkeleton class="loading month" text round />
209+
<NSkeleton class="loading day" text round />
210+
<NSkeleton class="loading week" text round />
211+
</div>
212+
<div v-else class="column">
213+
<NTime class="month" :time="date" format="MMM" />
214+
<NTime class="day" :time="date" format="dd" />
215+
<NTime class="week" :time="date" format="eee" />
216+
<NTime v-if="!sameYear" class="year" :time="date" format="yyyy" />
217+
</div>
218+
</Transition>
217219
</NFlex>
218220

219221
<slot v-if="item.type === ListScrollItemType.Placeholder">
@@ -253,6 +255,8 @@ const onClick = () => emit('onItemClick', { item: item?.value });
253255
<style lang="scss" scoped>
254256
@use '~/styles/mixin' as mixin;
255257
@use '~/styles/z-index' as layers;
258+
@use '~/styles/transition' as transition;
259+
@include transition.fade;
256260
257261
.timeline-item {
258262
height: var(--list-item-height, 145px);
@@ -286,11 +290,13 @@ const onClick = () => emit('onItemClick', { item: item?.value });
286290
top: 0;
287291
left: -3.75rem;
288292
width: 3.5rem;
293+
min-height: 5rem;
289294
color: var(--n-text-color);
290295
font-size: 14px;
291296
border-top: 1px solid var(--border-grey);
292-
transition: color 0.2s var(--n-bezier);
293-
will-change: color;
297+
transition:
298+
color 0.2s var(--n-bezier),
299+
border 0.2s var(--n-bezier);
294300
295301
&.today {
296302
color: var(--color-warning);
@@ -300,8 +306,16 @@ const onClick = () => emit('onItemClick', { item: item?.value });
300306
color: var(--trakt-red);
301307
}
302308
303-
.month {
309+
.column {
310+
display: flex;
311+
flex: 1 1 auto;
312+
flex-direction: column;
313+
align-items: center;
314+
justify-content: space-around;
304315
margin-top: 0.75rem;
316+
}
317+
318+
.month {
305319
font-weight: bold;
306320
}
307321
@@ -320,17 +334,17 @@ const onClick = () => emit('onItemClick', { item: item?.value });
320334
321335
&.month {
322336
width: 1.5rem;
323-
height: 0.8rem;
337+
height: 1rem;
324338
}
325339
326340
&.day {
327341
width: 2rem;
328-
height: 1rem;
342+
height: 1.25rem;
329343
}
330344
331345
&.week {
332346
width: 1.6rem;
333-
height: 0.75rem;
347+
height: 0.9rem;
334348
}
335349
}
336350
}
@@ -373,6 +387,7 @@ const onClick = () => emit('onItemClick', { item: item?.value });
373387
height: 100%;
374388
margin-left: calc(var(--n-icon-size) + 0.125rem);
375389
border-top: 1px solid transparent;
390+
transition: border 0.2s var(--n-bezier);
376391
377392
&__content {
378393
height: 100%;

src/stores/data/calendar.store.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { useAuthSettingsStoreRefs } from '~/stores/settings/auth.store';
1313
import { storage } from '~/utils/browser/browser-storage.utils';
1414
import { type CalendarItem, getEmptyWeeks, getLoadingPlaceholder, spaceDate } from '~/utils/calendar.utils';
1515
import { ErrorCount, type ErrorDictionary } from '~/utils/retry.utils';
16-
import { useSearchFilter } from '~/utils/store.utils';
16+
import { defaultDebounceLoadingDelay, useSearchFilter } from '~/utils/store.utils';
1717
import { clearProxy } from '~/utils/vue.utils';
1818

1919
const CalendarStoreConstants = {
@@ -123,7 +123,7 @@ export const useCalendarStore = defineStore(CalendarStoreConstants.Store, () =>
123123
if (mode === 'reload') calendar.value = getEmptyWeeks({ startDate, loading: true, days: days.value });
124124
else if (mode === 'start') calendar.value = [getLoadingPlaceholder(DateUtils.previous(1, endDate)), ...calendar.value];
125125
else if (mode === 'end') calendar.value = [...calendar.value, ...getEmptyWeeks({ startDate, loading: true, days: days.value })];
126-
}, 100);
126+
}, defaultDebounceLoadingDelay);
127127

128128
const query: TraktCalendarQuery = { start_date, days: days.value };
129129
if (extended.value) query.extended = TraktApiExtended.Full;

src/stores/data/releases.store.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { TraktService } from '~/services/trakt.service';
2020
import { storage } from '~/utils/browser/browser-storage.utils';
2121
import { type CalendarItem, getEmptyWeeks, getLoadingPlaceholder, spaceDate } from '~/utils/calendar.utils';
2222
import { ErrorCount, type ErrorDictionary } from '~/utils/retry.utils';
23+
import { defaultDebounceLoadingDelay } from '~/utils/store.utils';
2324
import { clearProxy } from '~/utils/vue.utils';
2425

2526
const ReleasesStoreConstants = {
@@ -172,7 +173,7 @@ export const useReleasesStore = defineStore(ReleasesStoreConstants.Store, () =>
172173
if (mode === 'reload') releases.value = getEmptyWeeks({ startDate, loading: true, days: days.value });
173174
else if (mode === 'start') releases.value = [getLoadingPlaceholder(DateUtils.previous(1, endDate)), ...releases.value];
174175
else if (mode === 'end') releases.value = [...releases.value, ...getEmptyWeeks({ startDate, loading: true, days: days.value })];
175-
}, 100);
176+
}, defaultDebounceLoadingDelay);
176177

177178
const query = {
178179
from: startDate,

src/utils/store.utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export const useDebouncedSearch = (search: Ref<string>, delay = 350, disabled?:
131131
return debouncedSearch;
132132
};
133133

134-
export const defaultDebounceLoadingDelay = 100;
134+
export const defaultDebounceLoadingDelay = 250;
135135
export type DebounceLoadingOptions<T> = { clear?: boolean; time?: number; splice?: (_data: T[], _placeholder: T[]) => T[] };
136136
export const debounceLoading = <T>(
137137
data: Ref<T[]>,

0 commit comments

Comments
 (0)