mirror of
https://github.com/jellyfin/jellyfin-vue.git
synced 2025-02-26 08:46:25 +00:00
perf&fix: avoid multiple backdrop rerenders, backdrop persistent after login page
Meta handling was reverted so it happens again at any time, regardless of query or param changes. The extra logic is negligible and we avoid edge cases where the path might be the same (like the first navigation) Signed-off-by: Fernando Fernández <ferferga@hotmail.com>
This commit is contained in:
parent
9f7dd5b9f1
commit
c25f047388
@ -18,8 +18,8 @@ import { computed } from 'vue';
|
||||
import { useRoute } from 'vue-router/auto';
|
||||
|
||||
const route = useRoute();
|
||||
const blurhash = computed(() => route.meta.backdrop?.blurhash);
|
||||
const opacity = computed(() => route.meta.backdrop?.opacity || 0.25);
|
||||
const blurhash = computed(() => route.meta.backdrop.blurhash);
|
||||
const opacity = computed(() => route.meta.backdrop.opacity);
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
@ -21,7 +21,7 @@
|
||||
keyboard
|
||||
a11y
|
||||
@swiper="(swiper) => swiperInstance = swiper"
|
||||
@slide-change="onSlideChange"
|
||||
@real-index-change="onSlideChange"
|
||||
@touch-start="onTouch"
|
||||
@touch-end="onTouch">
|
||||
<slot name="slides" />
|
||||
|
@ -112,7 +112,7 @@ function updateBackdrop(index: number): void {
|
||||
if (props.pageBackdrop) {
|
||||
const hash = getBlurhash(props.items[index], ImageType.Backdrop);
|
||||
|
||||
route.meta.backdrop = { blurhash: hash };
|
||||
route.meta.backdrop.blurhash = hash;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,7 @@ const defaultMeta: RouteMeta = {
|
||||
transparentLayout: false,
|
||||
admin: false,
|
||||
backdrop: {
|
||||
blurhash: undefined,
|
||||
opacity: 0.25
|
||||
}
|
||||
};
|
||||
@ -43,19 +44,14 @@ export function metaGuard(
|
||||
to: RouteLocationNormalized,
|
||||
from: RouteLocationNormalized
|
||||
): boolean | RouteLocationRaw {
|
||||
/**
|
||||
* Skip if it's in the same page (i.e for param or query changes)
|
||||
*/
|
||||
if (from.path !== to.path) {
|
||||
reactiveMeta.value = defu(to.meta, structuredClone(defaultMeta));
|
||||
to.meta = reactiveMeta.value;
|
||||
reactiveMeta.value = defu(to.meta, structuredClone(defaultMeta));
|
||||
to.meta = reactiveMeta.value;
|
||||
|
||||
if (from.meta.transition?.leave) {
|
||||
if (to.meta.transition) {
|
||||
to.meta.transition.enter = from.meta.transition.leave;
|
||||
} else {
|
||||
to.meta.transition = { enter: from.meta.transition.leave };
|
||||
}
|
||||
if (from.meta.transition?.leave) {
|
||||
if (to.meta.transition) {
|
||||
to.meta.transition.enter = from.meta.transition.leave;
|
||||
} else {
|
||||
to.meta.transition = { enter: from.meta.transition.leave };
|
||||
}
|
||||
}
|
||||
|
||||
|
2
frontend/types/global/plugins.d.ts
vendored
2
frontend/types/global/plugins.d.ts
vendored
@ -19,7 +19,7 @@ declare module 'vue-router' {
|
||||
transition?: RouteTransition;
|
||||
readonly admin: boolean;
|
||||
title?: string | null;
|
||||
backdrop: BackdropPayload;
|
||||
readonly backdrop: BackdropPayload;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user