mirror of
https://github.com/rommapp/romm.git
synced 2026-11-30 02:22:44 +01:00
feat(activity): add total sessions label to activity localization files
- Added "total-sessions" key to various language JSON files for activity localization. - Updated ActivityCard component to reflect changes in the activity view. - Enhanced Activity view to display a live session counter with a tooltip. - Introduced virtual scroll debugging to monitor performance in the gallery. - Adjusted layout styles for better responsiveness and visual consistency across components.
This commit is contained in:
@@ -9,5 +9,6 @@
|
||||
"no-activity": "В момента никой не играе",
|
||||
"now-playing": "Сега играе",
|
||||
"playing-on": "Играе на {device}",
|
||||
"playing-since": "Играе от {time}"
|
||||
"playing-since": "Играе от {time}",
|
||||
"total-sessions": "Общо сесии"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
"no-activity": "Nikdo právě nehraje",
|
||||
"now-playing": "Právě hraje",
|
||||
"playing-on": "Hraje na {device}",
|
||||
"playing-since": "Hraje od {time}"
|
||||
"playing-since": "Hraje od {time}",
|
||||
"total-sessions": "Celkem relací"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
"no-activity": "Derzeit spielt niemand",
|
||||
"now-playing": "Wird gespielt",
|
||||
"playing-on": "Spielt auf {device}",
|
||||
"playing-since": "Spielt seit {time}"
|
||||
"playing-since": "Spielt seit {time}",
|
||||
"total-sessions": "Sitzungen gesamt"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
"no-activity": "No one is currently playing",
|
||||
"now-playing": "Now Playing",
|
||||
"playing-on": "Playing on {device}",
|
||||
"playing-since": "Playing since {time}"
|
||||
"playing-since": "Playing since {time}",
|
||||
"total-sessions": "Total sessions"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
"no-activity": "No one is currently playing",
|
||||
"now-playing": "Now Playing",
|
||||
"playing-on": "Playing on {device}",
|
||||
"playing-since": "Playing since {time}"
|
||||
"playing-since": "Playing since {time}",
|
||||
"total-sessions": "Total sessions"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
"no-activity": "Nadie está jugando en este momento",
|
||||
"now-playing": "Jugando ahora",
|
||||
"playing-on": "Jugando en {device}",
|
||||
"playing-since": "Jugando desde {time}"
|
||||
"playing-since": "Jugando desde {time}",
|
||||
"total-sessions": "Sesiones totales"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
"no-activity": "Personne ne joue actuellement",
|
||||
"now-playing": "En cours de jeu",
|
||||
"playing-on": "Joue sur {device}",
|
||||
"playing-since": "Joue depuis {time}"
|
||||
"playing-since": "Joue depuis {time}",
|
||||
"total-sessions": "Sessions totales"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
"no-activity": "Jelenleg senki sem játszik",
|
||||
"now-playing": "Most játszik",
|
||||
"playing-on": "Ezen játszik: {device}",
|
||||
"playing-since": "Játszik ekkortól: {time}"
|
||||
"playing-since": "Játszik ekkortól: {time}",
|
||||
"total-sessions": "Összes munkamenet"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
"no-activity": "Al momento non sta giocando nessuno",
|
||||
"now-playing": "In gioco",
|
||||
"playing-on": "Sta giocando su {device}",
|
||||
"playing-since": "Sta giocando da {time}"
|
||||
"playing-since": "Sta giocando da {time}",
|
||||
"total-sessions": "Sessioni totali"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
"no-activity": "現在プレイ中のユーザーはいません",
|
||||
"now-playing": "プレイ中",
|
||||
"playing-on": "{device}でプレイ中",
|
||||
"playing-since": "{time}からプレイ中"
|
||||
"playing-since": "{time}からプレイ中",
|
||||
"total-sessions": "セッション合計"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
"no-activity": "현재 플레이 중인 사용자가 없습니다",
|
||||
"now-playing": "플레이 중",
|
||||
"playing-on": "{device}에서 플레이 중",
|
||||
"playing-since": "{time}부터 플레이 중"
|
||||
"playing-since": "{time}부터 플레이 중",
|
||||
"total-sessions": "전체 세션"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
"no-activity": "Nikt teraz nie gra",
|
||||
"now-playing": "Teraz gra",
|
||||
"playing-on": "Gra na {device}",
|
||||
"playing-since": "Gra od {time}"
|
||||
"playing-since": "Gra od {time}",
|
||||
"total-sessions": "Łącznie sesji"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
"no-activity": "Ninguém está jogando no momento",
|
||||
"now-playing": "Jogando agora",
|
||||
"playing-on": "Jogando em {device}",
|
||||
"playing-since": "Jogando desde {time}"
|
||||
"playing-since": "Jogando desde {time}",
|
||||
"total-sessions": "Sessões totais"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
"no-activity": "Nimeni nu joacă în acest moment",
|
||||
"now-playing": "Se joacă acum",
|
||||
"playing-on": "Joacă pe {device}",
|
||||
"playing-since": "Joacă din {time}"
|
||||
"playing-since": "Joacă din {time}",
|
||||
"total-sessions": "Total sesiuni"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
"no-activity": "Сейчас никто не играет",
|
||||
"now-playing": "Сейчас играют",
|
||||
"playing-on": "Играет на {device}",
|
||||
"playing-since": "Играет с {time}"
|
||||
"playing-since": "Играет с {time}",
|
||||
"total-sessions": "Всего сессий"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
"no-activity": "当前无人游玩",
|
||||
"now-playing": "正在游玩",
|
||||
"playing-on": "正在 {device} 上游玩",
|
||||
"playing-since": "自 {time} 起游玩"
|
||||
"playing-since": "自 {time} 起游玩",
|
||||
"total-sessions": "总会话数"
|
||||
}
|
||||
|
||||
@@ -9,5 +9,6 @@
|
||||
"no-activity": "目前無人遊玩",
|
||||
"now-playing": "正在遊玩",
|
||||
"playing-on": "正在 {device} 上遊玩",
|
||||
"playing-since": "自 {time} 起遊玩"
|
||||
"playing-since": "自 {time} 起遊玩",
|
||||
"total-sessions": "工作階段總數"
|
||||
}
|
||||
|
||||
@@ -324,6 +324,7 @@ const routes = [
|
||||
name: ROUTES.ACTIVITY,
|
||||
meta: {
|
||||
title: i18n.global.t("activity.active-sessions"),
|
||||
bare: true,
|
||||
},
|
||||
components: {
|
||||
// v2-only view; v1 has no activity concept so it redirects
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
<script setup lang="ts">
|
||||
// ActivityCard: a single "now playing" entry in the Activity grid.
|
||||
//
|
||||
// Portrait cover (RImg) with a pulsing LIVE badge over the top-right,
|
||||
// and a footer naming the game, its platform, and the player (avatar +
|
||||
// username) with an elapsed-since label. The whole card is a RouterLink
|
||||
// to the game detail view, so it participates in spatial / gamepad nav
|
||||
// (useWrapGridNav discovers it via the `a[href]` it renders).
|
||||
import { RAvatar, RChip, RIcon, RImg } from "@v2/lib";
|
||||
// Natural-aspect cover (GameCover) above a footer naming the game, its
|
||||
// platform, and the player (avatar + username) with an elapsed-since label.
|
||||
// The whole card is a RouterLink to the game detail view, so it participates
|
||||
// in spatial / gamepad nav (useWrapGridNav discovers it via the `a[href]` it
|
||||
// renders). No "live" badge: every card in this view is an active session by
|
||||
// definition, so the badge carried no per-card information — the page's
|
||||
// session counter is the single live indicator.
|
||||
import { RAvatar, RIcon } from "@v2/lib";
|
||||
import type { RouteLocationRaw } from "vue-router";
|
||||
import GameCover from "@/v2/components/shared/GameCover.vue";
|
||||
|
||||
interface Props {
|
||||
to: RouteLocationRaw;
|
||||
coverSrc: string;
|
||||
coverSrc: string | null;
|
||||
romName: string;
|
||||
platformName: string;
|
||||
username: string;
|
||||
avatarSrc: string;
|
||||
elapsedLabel: string;
|
||||
deviceType: string;
|
||||
liveLabel: string;
|
||||
}
|
||||
|
||||
defineProps<Props>();
|
||||
@@ -26,24 +28,17 @@ defineProps<Props>();
|
||||
|
||||
<template>
|
||||
<router-link :to="to" class="activity-card">
|
||||
<div class="activity-card__cover">
|
||||
<RImg
|
||||
:src="coverSrc"
|
||||
:alt="romName"
|
||||
width="100%"
|
||||
aspect-ratio="2/3"
|
||||
contain
|
||||
/>
|
||||
<RChip
|
||||
color="success"
|
||||
variant="flat"
|
||||
size="x-small"
|
||||
prepend-icon="mdi-access-point"
|
||||
class="activity-card__live"
|
||||
>
|
||||
{{ liveLabel }}
|
||||
</RChip>
|
||||
</div>
|
||||
<!-- GameCover is the canonical cover-art box (shared with the gallery
|
||||
cards, detail hero, players): it measures the image's natural ratio on
|
||||
load and sizes the box to it, so the card adopts the cover's true shape
|
||||
with no background showing. A 2:3 box is reserved while loading to
|
||||
avoid a reflow. -->
|
||||
<GameCover
|
||||
:rom="null"
|
||||
:cover-src="coverSrc"
|
||||
:title="romName"
|
||||
class="activity-card__art"
|
||||
/>
|
||||
|
||||
<div class="activity-card__body">
|
||||
<div class="activity-card__rom" :title="romName">
|
||||
@@ -72,45 +67,33 @@ defineProps<Props>();
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* No card surface — the cover is the card (gallery-card vocabulary): a
|
||||
rounded art box that lifts on hover, with the title/meta stacked below on
|
||||
the bare page. */
|
||||
.activity-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
background: var(--r-color-surface);
|
||||
border: 1px solid var(--r-color-border);
|
||||
border-radius: var(--r-radius-card);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* GameCover owns the radius / overflow / placeholder background; the card
|
||||
adds the hover lift (rise + shadow) on top. */
|
||||
.activity-card__art {
|
||||
transition:
|
||||
background var(--r-motion-fast) var(--r-motion-ease-out),
|
||||
border-color var(--r-motion-fast) var(--r-motion-ease-out),
|
||||
transform var(--r-motion-fast) var(--r-motion-ease-out);
|
||||
transform var(--r-motion-fast) var(--r-motion-ease-out),
|
||||
box-shadow var(--r-motion-fast) var(--r-motion-ease-out);
|
||||
}
|
||||
|
||||
.activity-card:hover {
|
||||
background: var(--r-color-surface-hover);
|
||||
border-color: var(--r-color-border-strong);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.activity-card__cover {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.activity-card__live {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
right: 8px;
|
||||
/* Soft glow so the badge reads as "live" against any cover art. */
|
||||
box-shadow: 0 0 12px
|
||||
color-mix(in srgb, var(--r-color-success) 60%, transparent);
|
||||
.activity-card:hover .activity-card__art {
|
||||
transform: translateY(-4px);
|
||||
box-shadow: 0 12px 28px color-mix(in srgb, black 45%, transparent);
|
||||
}
|
||||
|
||||
.activity-card__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
padding: 10px 12px 12px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import { useBreakpoint } from "@/v2/composables/useBreakpoint";
|
||||
import type { GamepadButtonEventDetail } from "@/v2/composables/useGamepad";
|
||||
import { useInputModality } from "@/v2/composables/useInputModality";
|
||||
import { useThemeMode } from "@/v2/composables/useThemeMode";
|
||||
import { useVirtualScrollDebug } from "@/v2/composables/useVirtualScrollDebug";
|
||||
|
||||
// — Breakpoint + viewport ------------------------------------------------
|
||||
const { xs, smAndUp, mdAndUp, lgAndUp, xlAndUp } = useBreakpoint();
|
||||
@@ -100,6 +101,12 @@ useEventListener(document, "focusout", () => {
|
||||
focusEl.value = document.activeElement;
|
||||
});
|
||||
|
||||
// — Virtual scroll -------------------------------------------------------
|
||||
// Published by the active virtualised gallery (null elsewhere). If windowing
|
||||
// is healthy, `rendered` stays ~constant (viewport + 2×overscan) however far
|
||||
// you scroll; a climbing value means the DOM isn't being trimmed.
|
||||
const { stats: vstats } = useVirtualScrollDebug();
|
||||
|
||||
// — Performance ----------------------------------------------------------
|
||||
const fps = useFps();
|
||||
const { isSupported: memSupported, memory } = useMemory();
|
||||
@@ -155,6 +162,27 @@ onMounted(() => {
|
||||
<span class="r-v2-debug__value">{{ focusLabel }}</span>
|
||||
</div>
|
||||
|
||||
<template v-if="vstats">
|
||||
<div class="r-v2-debug__row">
|
||||
<span class="r-v2-debug__label">vrows</span>
|
||||
<span class="r-v2-debug__value">
|
||||
<span class="r-v2-debug__accent">{{ vstats.renderedRows }}</span>
|
||||
/ {{ vstats.total }} rows · {{ vstats.label }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="r-v2-debug__row">
|
||||
<span class="r-v2-debug__label">vwin</span>
|
||||
<span class="r-v2-debug__value">
|
||||
{{ vstats.renderedCards }} cards · vp
|
||||
<template v-if="vstats.viewportLast >= vstats.viewportFirst">
|
||||
{{ vstats.viewportFirst }}–{{ vstats.viewportLast }}
|
||||
</template>
|
||||
<template v-else>—</template>
|
||||
· ov{{ vstats.overscan }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="r-v2-debug__row">
|
||||
<span class="r-v2-debug__label">perf</span>
|
||||
<span class="r-v2-debug__value">
|
||||
|
||||
@@ -430,9 +430,12 @@ function closeDialog() {
|
||||
padding-bottom: 24px;
|
||||
}
|
||||
|
||||
/* Flow-pack of cover cards — each tile adopts its cover's natural aspect
|
||||
(fixed height, width follows the art), like the gallery cards, instead of
|
||||
a rigid uniform-width grid. */
|
||||
.r-v2-sgdb__grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
padding: 12px 16px 16px;
|
||||
}
|
||||
@@ -440,6 +443,11 @@ function closeDialog() {
|
||||
.r-v2-sgdb__cover {
|
||||
appearance: none;
|
||||
position: relative;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
/* Reserve roughly a 2:3 slot so tiles don't collapse before their image
|
||||
loads; the tile then grows to the cover's true width on load. */
|
||||
min-width: 120px;
|
||||
border: 1px solid var(--r-color-border);
|
||||
border-radius: var(--r-radius-sm);
|
||||
padding: 0;
|
||||
@@ -456,9 +464,13 @@ function closeDialog() {
|
||||
}
|
||||
.r-v2-sgdb__cover-img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
aspect-ratio: 2 / 3;
|
||||
object-fit: cover;
|
||||
/* Fixed height, natural width — the card takes the cover's true aspect,
|
||||
never cropped. `max-width` caps the rare ultra-wide cover to the tile so
|
||||
it letterboxes instead of overflowing past its rounded corners. */
|
||||
height: 180px;
|
||||
width: auto;
|
||||
max-width: 100%;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
/* Provider logo overlay — top-right corner badge on the cover so the
|
||||
|
||||
@@ -46,6 +46,7 @@ import {
|
||||
onMounted,
|
||||
ref,
|
||||
watch,
|
||||
watchEffect,
|
||||
} from "vue";
|
||||
import { onBeforeRouteLeave, onBeforeRouteUpdate, useRoute } from "vue-router";
|
||||
import { useUISettings } from "@/composables/useUISettings";
|
||||
@@ -61,6 +62,7 @@ import { type ListSortKey } from "@/v2/components/Gallery/listColumns";
|
||||
import { GameCard, GameCardSkeleton } from "@/v2/components/GameCard";
|
||||
import { useBreakpoint } from "@/v2/composables/useBreakpoint";
|
||||
import { coverRatio, isBoxartStyle } from "@/v2/composables/useCoverArt";
|
||||
import { useDebugMode } from "@/v2/composables/useDebugMode";
|
||||
import { useGalleryCoverRatios } from "@/v2/composables/useGalleryCoverRatios";
|
||||
import { useGalleryFilterUrl } from "@/v2/composables/useGalleryFilterUrl";
|
||||
import { useGalleryMode } from "@/v2/composables/useGalleryMode";
|
||||
@@ -71,6 +73,7 @@ import {
|
||||
} from "@/v2/composables/useGalleryVirtualItems";
|
||||
import { useGridNav } from "@/v2/composables/useGridNav";
|
||||
import { useResponsiveColumns } from "@/v2/composables/useResponsiveColumns";
|
||||
import { useVirtualScrollDebug } from "@/v2/composables/useVirtualScrollDebug";
|
||||
import { useWebpSupport } from "@/v2/composables/useWebpSupport";
|
||||
import storeGalleryRoms from "@/v2/stores/galleryRoms";
|
||||
import storeGallerySelection from "@/v2/stores/gallerySelection";
|
||||
@@ -392,6 +395,52 @@ function onViewportRangeChange(range: { first: number; last: number }) {
|
||||
scheduleFetchSync(range);
|
||||
}
|
||||
|
||||
// Overscan kept on each side of the viewport — single source for both the
|
||||
// RVirtualScroller prop and the debug-overlay window math below.
|
||||
const VIRTUAL_OVERSCAN = 25;
|
||||
|
||||
// ── Debug overlay bridge ────────────────────────────────────────────
|
||||
// Publish the virtual scroller's window stats so the global DebugOverlay
|
||||
// can show whether windowing is actually trimming the DOM as you scroll.
|
||||
// Gated on `debugMode`: when off the effect early-returns before reading
|
||||
// any scroll state, so it never re-runs on scroll (zero runtime cost).
|
||||
const { enabled: debugMode } = useDebugMode();
|
||||
const virtualDebug = useVirtualScrollDebug();
|
||||
|
||||
watchEffect(() => {
|
||||
if (!debugMode.value) {
|
||||
virtualDebug.clear();
|
||||
return;
|
||||
}
|
||||
const items = virtualItems.value;
|
||||
const total = items.length;
|
||||
const vr = viewportRange.value;
|
||||
const empty = total === 0 || vr.last < vr.first;
|
||||
const first = empty ? 0 : Math.max(0, vr.first - VIRTUAL_OVERSCAN);
|
||||
const last = empty ? -1 : Math.min(total - 1, vr.last + VIRTUAL_OVERSCAN);
|
||||
// Count the cards actually mounted in the rendered window — grid rows fan
|
||||
// out into many cards, so this is the real DOM weight (not just row count).
|
||||
let renderedCards = 0;
|
||||
for (let i = first; i <= last; i++) {
|
||||
const it = items[i];
|
||||
if (!it) continue;
|
||||
if (it.kind === "row") renderedCards += it.endPosition - it.startPosition;
|
||||
else if (it.kind === "skeleton-row")
|
||||
renderedCards += Math.max(1, columns.value);
|
||||
else renderedCards += 1;
|
||||
}
|
||||
virtualDebug.publish({
|
||||
label: layout.value === "list" ? "gallery·list" : "gallery·grid",
|
||||
total,
|
||||
renderedRows: empty ? 0 : last - first + 1,
|
||||
renderedCards,
|
||||
viewportFirst: vr.first,
|
||||
viewportLast: vr.last,
|
||||
overscan: VIRTUAL_OVERSCAN,
|
||||
scrollTop: scrollerRef.value?.scrollTop ?? 0,
|
||||
});
|
||||
});
|
||||
|
||||
const visibleLettersSet = computed<Set<string>>(() => {
|
||||
const set = new Set<string>();
|
||||
const r = viewportRange.value;
|
||||
@@ -662,6 +711,9 @@ onBeforeUnmount(() => {
|
||||
visiblePositions.clear();
|
||||
inflowResizeObserver?.disconnect();
|
||||
inflowResizeObserver = null;
|
||||
// Drop the debug stats so the overlay doesn't show stale gallery numbers
|
||||
// on the next (non-gallery) route.
|
||||
virtualDebug.clear();
|
||||
// Restore body overflow so non-gallery routes scroll normally.
|
||||
document.body.style.overflow = prevBodyOverflow ?? "";
|
||||
prevBodyOverflow = null;
|
||||
@@ -721,7 +773,7 @@ defineExpose({
|
||||
ref="scrollerRef"
|
||||
:items="virtualItems"
|
||||
:get-item-height="getItemHeight"
|
||||
:overscan="25"
|
||||
:overscan="VIRTUAL_OVERSCAN"
|
||||
class="r-v2-shell__scroller r-v2-scroll-hidden"
|
||||
@update:viewport-range="onViewportRangeChange"
|
||||
>
|
||||
|
||||
@@ -588,6 +588,21 @@ onBeforeUnmount(() => {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
/* Bound the xs cover to its fixed column: at the fixed xs height a wide
|
||||
(landscape) cover would render wider than the column and spill out, getting
|
||||
clipped on the left. Cap the art box to a square (max-width = the height)
|
||||
and let the cover letterbox (contain) within, so the whole cover still
|
||||
shows at its true aspect. Portrait/square covers are unaffected (their
|
||||
natural width already fits, and contain renders identically to cover when
|
||||
the box matches the cover's ratio). Scoped to the list cover only — the
|
||||
gallery grid keeps its natural-width flow. */
|
||||
.game-list-row__cover :deep(.r-gc__art) {
|
||||
max-width: var(--r-card-art-h);
|
||||
}
|
||||
.game-list-row__cover :deep(.r-gc__art > img) {
|
||||
object-fit: contain !important;
|
||||
}
|
||||
|
||||
.game-list-row__title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -279,8 +279,11 @@ watch(
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--r-color-border-strong) transparent;
|
||||
padding: 10px 8px 6px;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
||||
/* Flow-pack of natural-width cards (like the gallery) rather than a rigid
|
||||
uniform-width grid — each GameCard renders at its cover's true aspect, so
|
||||
a wide cover would spill out of a fixed grid cell. */
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 18px 14px;
|
||||
align-content: start;
|
||||
transition:
|
||||
@@ -295,6 +298,9 @@ watch(
|
||||
}
|
||||
|
||||
.match-grid__card-cell {
|
||||
/* Shrink-wrap the card's natural width and never shrink below it (a fixed
|
||||
-height card shrunk on the cross axis would crop its cover). */
|
||||
flex: 0 0 auto;
|
||||
/* Stagger entrance — same vocabulary the cover-source picker uses,
|
||||
so opening the dialog and selecting a match share a consistent
|
||||
"cascading reveal" feel. `--i` is the card's index, set inline. */
|
||||
@@ -429,6 +435,11 @@ watch(
|
||||
.match-grid__source {
|
||||
appearance: none;
|
||||
position: relative;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
/* Reserve roughly a 2:3 slot so the tile doesn't collapse before the
|
||||
source cover loads; it grows to the cover's true width on load. */
|
||||
min-width: 114px;
|
||||
background: transparent;
|
||||
border: 2px solid transparent;
|
||||
border-radius: calc(var(--r-radius-art) + 2px);
|
||||
@@ -465,9 +476,14 @@ watch(
|
||||
|
||||
.match-grid__source-img {
|
||||
display: block;
|
||||
width: 120px;
|
||||
/* Fixed height, natural width — the tile takes the cover's true aspect,
|
||||
never cropped (matches the gallery cards). `max-width` caps the rare
|
||||
ultra-wide cover to the tile so it letterboxes instead of overflowing
|
||||
and getting clipped by the panel. */
|
||||
height: 162px;
|
||||
object-fit: cover;
|
||||
width: auto;
|
||||
max-width: 100%;
|
||||
object-fit: contain;
|
||||
border-radius: var(--r-radius-art);
|
||||
background: var(--r-color-cover-placeholder);
|
||||
}
|
||||
|
||||
@@ -321,22 +321,34 @@ watch(
|
||||
}
|
||||
|
||||
.match-list__row-cover {
|
||||
/* Fixed-width alignment column (keeps the row titles aligned) inside which
|
||||
the cover card sits at its natural aspect — same idea as the gallery
|
||||
list view's dedicated cover column. */
|
||||
flex-shrink: 0;
|
||||
width: 42px;
|
||||
width: 56px;
|
||||
height: 56px;
|
||||
border-radius: var(--r-radius-sm);
|
||||
overflow: hidden;
|
||||
background: var(--r-color-cover-placeholder);
|
||||
display: grid;
|
||||
place-items: center;
|
||||
}
|
||||
.match-list__row-cover img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
/* The card itself takes the cover's true aspect (fixed height, width
|
||||
follows the art); an ultra-wide cover letterboxes within the column. */
|
||||
height: 56px;
|
||||
width: auto;
|
||||
max-width: 56px;
|
||||
object-fit: contain;
|
||||
border-radius: var(--r-radius-sm);
|
||||
background: var(--r-color-cover-placeholder);
|
||||
display: block;
|
||||
}
|
||||
.match-list__row-cover-placeholder {
|
||||
/* No cover → a uniform square chip with the title initial. */
|
||||
display: grid;
|
||||
place-items: center;
|
||||
width: 42px;
|
||||
height: 56px;
|
||||
border-radius: var(--r-radius-sm);
|
||||
background: var(--r-color-cover-placeholder);
|
||||
font-size: 18px;
|
||||
font-weight: var(--r-font-weight-bold);
|
||||
color: var(--r-color-fg-muted);
|
||||
@@ -456,6 +468,11 @@ watch(
|
||||
.match-list__source {
|
||||
appearance: none;
|
||||
position: relative;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
/* Reserve roughly a 2:3 slot so the tile doesn't collapse before the
|
||||
source cover loads; it grows to the cover's true width on load. */
|
||||
min-width: 105px;
|
||||
background: transparent;
|
||||
border: 2px solid transparent;
|
||||
border-radius: calc(var(--r-radius-art) + 2px);
|
||||
@@ -492,9 +509,14 @@ watch(
|
||||
|
||||
.match-list__source-img {
|
||||
display: block;
|
||||
width: 110px;
|
||||
/* Fixed height, natural width — the tile takes the cover's true aspect,
|
||||
never cropped (matches the gallery cards). `max-width` caps the rare
|
||||
ultra-wide cover to the tile so it letterboxes instead of overflowing
|
||||
and getting clipped by the panel. */
|
||||
height: 148px;
|
||||
object-fit: cover;
|
||||
width: auto;
|
||||
max-width: 100%;
|
||||
object-fit: contain;
|
||||
border-radius: var(--r-radius-art);
|
||||
background: var(--r-color-cover-placeholder);
|
||||
}
|
||||
|
||||
45
frontend/src/v2/composables/useVirtualScrollDebug/index.ts
Normal file
45
frontend/src/v2/composables/useVirtualScrollDebug/index.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
// useVirtualScrollDebug — shared diagnostics bridge from the active
|
||||
// virtualised scroller to the DebugOverlay.
|
||||
//
|
||||
// Module-level singleton (mirrors the useDebugMode / useUiVersion pattern):
|
||||
// the virtualised gallery publishes its window stats here on each scroll and
|
||||
// the globally-mounted DebugOverlay reads them. `stats` is null whenever no
|
||||
// virtual scroller is reporting (non-gallery routes, or debug mode off), so
|
||||
// the overlay can simply `v-if` the block away.
|
||||
//
|
||||
// The point is to make windowing health observable: if virtualisation is
|
||||
// working, `renderedRows` / `renderedCards` stay roughly constant
|
||||
// (viewport + 2×overscan) as you scroll a huge library; if they climb with
|
||||
// the scroll position, the window isn't being trimmed and that's the freeze.
|
||||
import { ref } from "vue";
|
||||
|
||||
export interface VirtualScrollStats {
|
||||
/** Which scroller is reporting (e.g. "gallery·grid" / "gallery·list"). */
|
||||
label: string;
|
||||
/** Total virtual items (rows + headers) the scroller is managing. */
|
||||
total: number;
|
||||
/** Items currently mounted in the DOM (viewport + overscan both sides). */
|
||||
renderedRows: number;
|
||||
/** Cards/rows actually painted inside the rendered window — the real DOM
|
||||
* weight (grid rows fan out into many cards). */
|
||||
renderedCards: number;
|
||||
/** Viewport-visible item range (inclusive). `last < first` ⇒ empty. */
|
||||
viewportFirst: number;
|
||||
viewportLast: number;
|
||||
/** Overscan count the scroller keeps on each side of the viewport. */
|
||||
overscan: number;
|
||||
/** Current scroll offset of the scroll container, in px. */
|
||||
scrollTop: number;
|
||||
}
|
||||
|
||||
const stats = ref<VirtualScrollStats | null>(null);
|
||||
|
||||
export function useVirtualScrollDebug() {
|
||||
function publish(next: VirtualScrollStats) {
|
||||
stats.value = next;
|
||||
}
|
||||
function clear() {
|
||||
stats.value = null;
|
||||
}
|
||||
return { stats, publish, clear };
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
// Elapsed-time labels are recomputed off a `now` ref that ticks every
|
||||
// 30s, so "5m ago" advances without a full refetch. The grid is wired
|
||||
// to `useWrapGridNav` so arrow keys / gamepad move across the cards.
|
||||
import { RChip, RSkeletonBlock } from "@v2/lib";
|
||||
import { RIcon, RSkeletonBlock, RTooltip } from "@v2/lib";
|
||||
import { storeToRefs } from "pinia";
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
@@ -17,10 +17,8 @@ import storeActivity from "@/stores/activity";
|
||||
import { FRONTEND_RESOURCES_PATH } from "@/utils";
|
||||
import ActivityCard from "@/v2/components/Activity/ActivityCard.vue";
|
||||
import EmptyState from "@/v2/components/shared/EmptyState.vue";
|
||||
import PageHeader from "@/v2/components/shared/PageHeader.vue";
|
||||
import { useWebpSupport } from "@/v2/composables/useWebpSupport";
|
||||
import { useWrapGridNav } from "@/v2/composables/useWrapGridNav";
|
||||
import { getMissingCoverImage } from "@/v2/utils/covers";
|
||||
import { userAvatarUrl } from "@/v2/utils/userAvatar";
|
||||
|
||||
const { t } = useI18n();
|
||||
@@ -64,8 +62,10 @@ function romRoute(entry: ActivityEntry) {
|
||||
return { name: ROUTES.ROM, params: { rom: entry.rom_id } };
|
||||
}
|
||||
|
||||
function coverSrc(entry: ActivityEntry): string {
|
||||
if (!entry.rom_cover_path) return getMissingCoverImage(entry.rom_name);
|
||||
// Null when the rom has no cover — GameCover then paints its own canonical
|
||||
// placeholder (title initial) instead of a baked-in missing-cover image.
|
||||
function coverSrc(entry: ActivityEntry): string | null {
|
||||
if (!entry.rom_cover_path) return null;
|
||||
return `${FRONTEND_RESOURCES_PATH}/${toWebp(entry.rom_cover_path)}`;
|
||||
}
|
||||
|
||||
@@ -96,19 +96,24 @@ function elapsedLabel(startedAt: string): string {
|
||||
|
||||
<template>
|
||||
<div class="r-v2-activity">
|
||||
<PageHeader :title="t('activity.active-sessions')">
|
||||
<template #count>
|
||||
<RChip
|
||||
v-if="activities.length > 0"
|
||||
color="success"
|
||||
variant="translucent"
|
||||
size="small"
|
||||
prepend-icon="mdi-access-point"
|
||||
>
|
||||
{{ activities.length }}
|
||||
</RChip>
|
||||
</template>
|
||||
</PageHeader>
|
||||
<!-- Counter top-left — keeps the live session total visible without the
|
||||
page-level header the other Settings sections don't carry. The label
|
||||
lives in a tooltip so the chip itself stays a compact icon + count;
|
||||
the dot pulses while at least one session is live. -->
|
||||
<div class="r-v2-activity__head">
|
||||
<div
|
||||
class="r-v2-activity__total"
|
||||
:class="{ 'r-v2-activity__total--live': activities.length > 0 }"
|
||||
>
|
||||
<RIcon
|
||||
icon="mdi-access-point"
|
||||
size="16"
|
||||
class="r-v2-activity__total-icon"
|
||||
/>
|
||||
<span class="r-v2-activity__total-count">{{ activities.length }}</span>
|
||||
<RTooltip activator="parent" :text="t('activity.total-sessions')" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="r-v2-activity__grid">
|
||||
<RSkeletonBlock
|
||||
@@ -129,8 +134,10 @@ function elapsedLabel(startedAt: string): string {
|
||||
|
||||
<div v-else ref="gridRoot" class="r-v2-activity__grid">
|
||||
<ActivityCard
|
||||
v-for="entry in activities"
|
||||
v-for="(entry, i) in activities"
|
||||
:key="`${entry.user_id}-${entry.device_id}`"
|
||||
class="r-v2-card-fade"
|
||||
:style="{ '--card-fade-i': i }"
|
||||
:to="romRoute(entry)"
|
||||
:cover-src="coverSrc(entry)"
|
||||
:rom-name="entry.rom_name"
|
||||
@@ -139,26 +146,81 @@ function elapsedLabel(startedAt: string): string {
|
||||
:avatar-src="avatarSrc(entry)"
|
||||
:elapsed-label="elapsedLabel(entry.started_at)"
|
||||
:device-type="entry.device_type"
|
||||
:live-label="t('activity.live')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* Bare Settings route (no outer glass panel) — the SettingsLayout content
|
||||
column already owns the page gutters, so the view itself adds none. */
|
||||
.r-v2-activity {
|
||||
padding: 32px var(--r-row-pad) 60px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* Counter row — left-aligned stat replacing the page header. */
|
||||
.r-v2-activity__head {
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.r-v2-activity__total {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 7px;
|
||||
padding: 6px 12px;
|
||||
border-radius: var(--r-radius-pill);
|
||||
background: var(--r-color-surface);
|
||||
border: 1px solid var(--r-color-border);
|
||||
color: var(--r-color-fg-muted);
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.r-v2-activity__total-icon {
|
||||
color: var(--r-color-fg-faint);
|
||||
}
|
||||
.r-v2-activity__total--live .r-v2-activity__total-icon {
|
||||
color: var(--r-color-success);
|
||||
/* Soft pulse while sessions are live — echoes the cards' LIVE chip. */
|
||||
animation: r-v2-activity-pulse 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.r-v2-activity__total-count {
|
||||
font-size: var(--r-font-size-md);
|
||||
font-weight: var(--r-font-weight-bold);
|
||||
font-variant-numeric: tabular-nums;
|
||||
color: var(--r-color-fg);
|
||||
}
|
||||
.r-v2-activity__total--live .r-v2-activity__total-count {
|
||||
color: var(--r-color-success);
|
||||
}
|
||||
|
||||
@keyframes r-v2-activity-pulse {
|
||||
0%,
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.35;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.r-v2-activity__total--live .r-v2-activity__total-icon {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
|
||||
.r-v2-activity__grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
|
||||
gap: 20px 16px;
|
||||
/* Cards take their cover's natural height, so don't stretch them to the
|
||||
row's tallest item — let each sit at its true height, top-aligned. */
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
html[data-bp~="xs"] .r-v2-activity {
|
||||
padding: 16px var(--r-row-pad) 80px;
|
||||
}
|
||||
html[data-bp~="xs"] .r-v2-activity__grid {
|
||||
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
||||
gap: 16px 10px;
|
||||
|
||||
Reference in New Issue
Block a user