Tidy up overly verbose LLM comments
This commit is contained in:
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "immich-public-proxy",
|
"name": "immich-public-proxy",
|
||||||
"version": "3.3.2",
|
"version": "3.3.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "immich-public-proxy",
|
"name": "immich-public-proxy",
|
||||||
"version": "3.3.2",
|
"version": "3.3.1",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"archiver": "^7.0.1",
|
"archiver": "^7.0.1",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "immich-public-proxy",
|
"name": "immich-public-proxy",
|
||||||
"version": "3.3.2",
|
"version": "3.3.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "concurrently -n server,client -c blue,green \"tsx watch src/index.ts\" \"tsc -w -p tsconfig.client.json\"",
|
"dev": "concurrently -n server,client -c blue,green \"tsx watch src/index.ts\" \"tsc -w -p tsconfig.client.json\"",
|
||||||
"build": "tsc && tsc -p tsconfig.client.json",
|
"build": "tsc && tsc -p tsconfig.client.json",
|
||||||
|
|||||||
+7
-15
@@ -15,12 +15,7 @@ export const MOBILE_COLS = 3
|
|||||||
export const IMAGE_LOAD_MARGIN_PX = 300
|
export const IMAGE_LOAD_MARGIN_PX = 300
|
||||||
export const SCROLL_SETTLE_MS = 100
|
export const SCROLL_SETTLE_MS = 100
|
||||||
export const BUFFER_VIEWPORTS = 1
|
export const BUFFER_VIEWPORTS = 1
|
||||||
// Upper bound on how many already-loaded tiles we keep permanently mounted
|
// Cap on state.stickyTiles: dozens of screens of scroll-back, bounded DOM
|
||||||
// (see state.stickyTiles). ~1500 covers dozens of screens of scroll-back so
|
|
||||||
// revisiting recently-seen thumbnails never flickers, while capping retained
|
|
||||||
// DOM / decoded-image memory so a 100k-photo album can't grow unbounded as
|
|
||||||
// the user scrolls. Least-recently-visible tiles past this count fall back to
|
|
||||||
// normal virtualisation and re-pin if scrolled back to.
|
|
||||||
export const STICKY_TILE_LIMIT = 1500
|
export const STICKY_TILE_LIMIT = 1500
|
||||||
// Height reserved for each month header (must agree with .group-header CSS)
|
// Height reserved for each month header (must agree with .group-header CSS)
|
||||||
export const HEADER_HEIGHT = 48
|
export const HEADER_HEIGHT = 48
|
||||||
@@ -80,15 +75,12 @@ export const state = {
|
|||||||
lastContainerW: 0,
|
lastContainerW: 0,
|
||||||
renderedTiles: new Map<number, HTMLAnchorElement>(),
|
renderedTiles: new Map<number, HTMLAnchorElement>(),
|
||||||
renderedHeaders: new Map<string, HTMLElement>(),
|
renderedHeaders: new Map<string, HTMLElement>(),
|
||||||
// Tile indices whose <img> has fired `load` at least once. While an index
|
/*
|
||||||
// is in this set virtualize() never removes its tile, so scrolling back to
|
Indices of tiles whose <img> has loaded. virtualize() never removes these,
|
||||||
// an already-seen thumbnail shows the cached image with no placeholder /
|
so scrolling back reuses the mounted <img>: no placeholder flicker and no
|
||||||
// fade-in flicker. Insertion order is maintained as most-recently-visible-
|
re-fetch (password-protected shares serve thumbnails `no-store`). Ordered
|
||||||
// last and the set is trimmed to STICKY_TILE_LIMIT each virtualize() pass,
|
most-recently-visible last and trimmed to STICKY_TILE_LIMIT from the head.
|
||||||
// so a huge album can't accumulate unbounded mounted DOM. Tiles that have
|
*/
|
||||||
// not loaded yet get the normal lazy create / remove treatment, so large
|
|
||||||
// albums still lazy-load on first scroll-into-view. Cleared on a layout
|
|
||||||
// recompute (see computeLayoutAndRender) because tile geometry changes.
|
|
||||||
stickyTiles: new Set<number>(),
|
stickyTiles: new Set<number>(),
|
||||||
// Selection mode (mode-toggle UX: hidden checkmarks until activated)
|
// Selection mode (mode-toggle UX: hidden checkmarks until activated)
|
||||||
selectMode: false,
|
selectMode: false,
|
||||||
|
|||||||
@@ -75,13 +75,8 @@ export function createTile (index: number): HTMLAnchorElement {
|
|||||||
// white flash between `img.src` being set and the bytes actually painting).
|
// white flash between `img.src` being set and the bytes actually painting).
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
img.classList.add('loaded')
|
img.classList.add('loaded')
|
||||||
// Pin this tile: once loaded it is never virtualised out again, so a
|
// Pin the tile (see state.stickyTiles) unless it was virtualised out
|
||||||
// scroll back up reuses this exact <img> instead of rebuilding it in a
|
// mid-load, in which case this <a> is detached and must not pin its replacement
|
||||||
// blank/placeholder state. See state.stickyTiles / virtualize().
|
|
||||||
// Guard: if this tile was virtualised out before its (in-flight) image
|
|
||||||
// finished, the load still fires on the now-detached <img>. Only pin the
|
|
||||||
// index while this <a> is still the live tile for it, so a stale request
|
|
||||||
// can't mark a not-yet-loaded replacement tile as sticky.
|
|
||||||
if (state.renderedTiles.get(index) === a) state.stickyTiles.add(index)
|
if (state.renderedTiles.get(index) === a) state.stickyTiles.add(index)
|
||||||
}
|
}
|
||||||
a.appendChild(img)
|
a.appendChild(img)
|
||||||
|
|||||||
@@ -57,13 +57,8 @@ export function virtualize () {
|
|||||||
if (l.top > bottom) break
|
if (l.top > bottom) break
|
||||||
neededTiles.add(l.index)
|
neededTiles.add(l.index)
|
||||||
}
|
}
|
||||||
// Sticky (already-loaded) tiles: keep them in the "needed" set so
|
// Sticky tiles (see state.stickyTiles): bump in-range ones to the tail,
|
||||||
// syncRendered never removes them and a scroll-back shows the cached image
|
// evict overflow from the head, keep the rest. Only ever blocks removal.
|
||||||
// with no flicker. Bounded so a very large album can't grow unbounded DOM:
|
|
||||||
// 1. bump currently-visible sticky tiles to most-recently-used (set tail),
|
|
||||||
// 2. evict the oldest overflow that isn't on screen right now,
|
|
||||||
// 3. union whatever remains into neededTiles (all already rendered, so
|
|
||||||
// this only blocks removal - it never triggers a re-create).
|
|
||||||
for (const index of neededTiles) {
|
for (const index of neededTiles) {
|
||||||
if (state.stickyTiles.delete(index)) state.stickyTiles.add(index)
|
if (state.stickyTiles.delete(index)) state.stickyTiles.add(index)
|
||||||
}
|
}
|
||||||
@@ -149,10 +144,7 @@ export function computeLayoutAndRender () {
|
|||||||
state.renderedTiles.clear()
|
state.renderedTiles.clear()
|
||||||
for (const [, el] of state.renderedHeaders) el.remove()
|
for (const [, el] of state.renderedHeaders) el.remove()
|
||||||
state.renderedHeaders.clear()
|
state.renderedHeaders.clear()
|
||||||
// Tile positions/sizes have changed, so the old pinned <img> elements are
|
// Otherwise virtualize() would rebuild every seen tile at once
|
||||||
// gone. Drop the sticky set and let tiles re-pin themselves as they reload
|
|
||||||
// for the new layout - otherwise the virtualize() below would rebuild every
|
|
||||||
// previously-seen tile at once.
|
|
||||||
state.stickyTiles.clear()
|
state.stickyTiles.clear()
|
||||||
|
|
||||||
virtualize()
|
virtualize()
|
||||||
@@ -175,8 +167,6 @@ export function loadVisibleTiles () {
|
|||||||
for (const a of state.renderedTiles.values()) {
|
for (const a of state.renderedTiles.values()) {
|
||||||
const img = a.firstElementChild
|
const img = a.firstElementChild
|
||||||
if (!(img instanceof HTMLImageElement)) continue
|
if (!(img instanceof HTMLImageElement)) continue
|
||||||
// Fast-path: a finished load with no parked data-src has nothing to
|
|
||||||
// toggle. Matters now that sticky tiles keep this map large.
|
|
||||||
if (img.complete && img.src && !img.dataset.src) continue
|
if (img.complete && img.src && !img.dataset.src) continue
|
||||||
const aTopInVp = containerTop + parseFloat(a.style.top || '0')
|
const aTopInVp = containerTop + parseFloat(a.style.top || '0')
|
||||||
const aHeight = parseFloat(a.style.height || '0')
|
const aHeight = parseFloat(a.style.height || '0')
|
||||||
|
|||||||
Reference in New Issue
Block a user