merge: origin/dev (widget-only integration refactor)
Resolve conflicts keeping our simplified request handlers (with TTL cache) and adopting dev's new release-provider + timetable direct implementations. Remove per-query staleTime from timetable widget.
This commit is contained in:
91 files changed
+2306
-2545
No files matched your search
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import type { Dispatch, SetStateAction } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Box, Center, Group, Image, Stack, Text } from "@mantine/core";
|
||||
import { IconAlertCircle, IconCalendar } from "@tabler/icons-react";
|
||||
|
||||
@@ -26,6 +26,15 @@ export default function ImmichAlbumCarouselWidget({
|
||||
{ enabled: Boolean(options.albumId) },
|
||||
);
|
||||
|
||||
const photoAssets = useMemo(() => {
|
||||
const assets = album?.assets.filter((asset) => asset.type === "IMAGE") ?? [];
|
||||
return options.randomizePhotos ? shuffle(assets) : assets;
|
||||
}, [album?.assets, options.randomizePhotos]);
|
||||
|
||||
useEffect(() => {
|
||||
setCurrentPhotoIndex(0);
|
||||
}, [photoAssets]);
|
||||
|
||||
if (!options.albumId) {
|
||||
return <NoAlbumSelected />;
|
||||
}
|
||||
@@ -36,8 +45,6 @@ export default function ImmichAlbumCarouselWidget({
|
||||
return <NoPhotosInAlbum />;
|
||||
}
|
||||
|
||||
const photoAssets = album.assets.filter((asset) => asset.type === "IMAGE");
|
||||
|
||||
if (photoAssets.length === 0) {
|
||||
return <NoPhotosInAlbum />;
|
||||
}
|
||||
@@ -53,6 +60,19 @@ export default function ImmichAlbumCarouselWidget({
|
||||
);
|
||||
}
|
||||
|
||||
function shuffle<T>(items: T[]) {
|
||||
const shuffled = [...items];
|
||||
for (let index = shuffled.length - 1; index > 0; index--) {
|
||||
const randomIndex = Math.floor(Math.random() * (index + 1));
|
||||
const current = shuffled[index];
|
||||
const random = shuffled[randomIndex];
|
||||
if (current === undefined || random === undefined) continue;
|
||||
shuffled[index] = random;
|
||||
shuffled[randomIndex] = current;
|
||||
}
|
||||
return shuffled;
|
||||
}
|
||||
|
||||
interface CarouselProps {
|
||||
assets: {
|
||||
id: string;
|
||||
|
||||
Reference in new issue
Block a user