From 8dcb7ea929e3eda64e3371e5d5d0b26e4c785bdf Mon Sep 17 00:00:00 2001 From: ajnart Date: Tue, 21 Jul 2026 11:20:20 +0200 Subject: [PATCH] fix(immich): add all photos album option --- .../docs/widgets/immich-album-carousel/index.ts | 5 +++-- packages/translation/src/lang/en.json | 3 ++- .../widgets/src/immich/album-carousel/component.tsx | 3 ++- .../widgets/src/immich/album-carousel/constants.ts | 1 + packages/widgets/src/immich/album-carousel/index.ts | 13 ++++++++++++- 5 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 packages/widgets/src/immich/album-carousel/constants.ts diff --git a/apps/docs/docs/widgets/immich-album-carousel/index.ts b/apps/docs/docs/widgets/immich-album-carousel/index.ts index 7e956bae6..72a0b2211 100644 --- a/apps/docs/docs/widgets/immich-album-carousel/index.ts +++ b/apps/docs/docs/widgets/immich-album-carousel/index.ts @@ -10,9 +10,10 @@ export const immichAlbumCarouselWidget: WidgetDefinition = { items: [ { name: "Album", - description: "Select an Immich album, or leave empty to show random photos from your full library.", + description: + "Select an Immich album or All photos. An empty selection also shows random photos from your full library.", values: { type: "string" }, - defaultValue: "", + defaultValue: "All photos", }, { name: "Interval in seconds", diff --git a/packages/translation/src/lang/en.json b/packages/translation/src/lang/en.json index 0ce813d33..ae89ad4df 100644 --- a/packages/translation/src/lang/en.json +++ b/packages/translation/src/lang/en.json @@ -3006,10 +3006,11 @@ }, "immich-albumCarousel": { "name": "Immich Album", + "allPhotos": "All photos", "option": { "albumId": { "label": "Album", - "description": "Select an Immich album, or leave empty to show random photos from your full library." + "description": "Select an Immich album or All photos. An empty selection also shows random photos from your full library." }, "rotationIntervalSeconds": { "label": "Interval in seconds", diff --git a/packages/widgets/src/immich/album-carousel/component.tsx b/packages/widgets/src/immich/album-carousel/component.tsx index 85323b647..49bb4ceec 100644 --- a/packages/widgets/src/immich/album-carousel/component.tsx +++ b/packages/widgets/src/immich/album-carousel/component.tsx @@ -11,6 +11,7 @@ import { useI18n } from "@homarr/translation/client"; import { WidgetEmptyState } from "../../common/empty-state"; import type { WidgetComponentProps } from "../../definition"; import classes from "./component.module.css"; +import { ALL_PHOTOS_ALBUM_ID } from "./constants"; export default function ImmichAlbumCarouselWidget({ integrationIds, @@ -21,7 +22,7 @@ export default function ImmichAlbumCarouselWidget({ const { data: album } = clientApi.widget.immich.getAlbum.useQuery( { integrationId: integrationIds[0] ?? "", - albumId: options.albumId || undefined, + albumId: options.albumId && options.albumId !== ALL_PHOTOS_ALBUM_ID ? options.albumId : undefined, }, { enabled: integrationIds.length > 0 }, ); diff --git a/packages/widgets/src/immich/album-carousel/constants.ts b/packages/widgets/src/immich/album-carousel/constants.ts new file mode 100644 index 000000000..0371578de --- /dev/null +++ b/packages/widgets/src/immich/album-carousel/constants.ts @@ -0,0 +1 @@ +export const ALL_PHOTOS_ALBUM_ID = "all"; diff --git a/packages/widgets/src/immich/album-carousel/index.ts b/packages/widgets/src/immich/album-carousel/index.ts index 0ae11ef79..8c4223ef3 100644 --- a/packages/widgets/src/immich/album-carousel/index.ts +++ b/packages/widgets/src/immich/album-carousel/index.ts @@ -2,9 +2,11 @@ import { IconPhoto } from "@tabler/icons-react"; import z from "zod"; import { clientApi } from "@homarr/api/client"; +import { useScopedI18n } from "@homarr/translation/client"; import { createWidgetDefinition } from "../../definition"; import { optionsBuilder } from "../../options"; +import { ALL_PHOTOS_ALBUM_ID } from "./constants"; export const { definition, componentLoader } = createWidgetDefinition("immich-albumCarousel", { icon: IconPhoto, @@ -15,9 +17,11 @@ export const { definition, componentLoader } = createWidgetDefinition("immich-al createOptions() { return optionsBuilder.from((factory) => ({ albumId: factory.integrationSelect({ + defaultValue: ALL_PHOTOS_ALBUM_ID, withDescription: true, clearable: true, useOptions: (integrationIds: string[]) => { + const t = useScopedI18n("widget.immich-albumCarousel"); const { data = [], isPending, @@ -26,7 +30,14 @@ export const { definition, componentLoader } = createWidgetDefinition("immich-al { integrationId: integrationIds[0] ?? "" }, { enabled: integrationIds.length > 0, staleTime: 15 * 60 * 1000 }, ); - return { data: data.map((album) => ({ value: album.id, label: album.albumName })), isPending, isError }; + return { + data: [ + { value: ALL_PHOTOS_ALBUM_ID, label: t("allPhotos") }, + ...data.map((album) => ({ value: album.id, label: album.albumName })), + ], + isPending, + isError, + }; }, }), rotationIntervalSeconds: factory.number({