fix: refine widget modernization
This commit is contained in:
1 parent
6f2cd7fc2b
commit
777bbd89a1
44 files changed
+259
-320
No files matched your search
@@ -27,13 +27,8 @@ export default function ImmichAlbumCarouselWidget({
|
||||
displayMode = "compact",
|
||||
widgetStateRef,
|
||||
}: WidgetComponentProps<"immich-albumCarousel">) {
|
||||
const persistedState = widgetStateRef?.current?.immichAlbumCarousel as
|
||||
| { currentPhotoIndex?: number; paused?: boolean }
|
||||
| undefined;
|
||||
const [currentPhotoIndex, setCurrentPhotoIndex] = useState(() =>
|
||||
typeof persistedState?.currentPhotoIndex === "number" ? persistedState.currentPhotoIndex : 0,
|
||||
);
|
||||
const [paused, setPaused] = useState(persistedState?.paused === true);
|
||||
const [currentPhotoIndex, setCurrentPhotoIndex] = useState(0);
|
||||
const [paused, setPaused] = useState(false);
|
||||
|
||||
const { data: album } = clientApi.widget.immich.getAlbum.useQuery(
|
||||
{
|
||||
@@ -53,14 +48,6 @@ export default function ImmichAlbumCarouselWidget({
|
||||
setCurrentPhotoIndex((current) => Math.min(current, photoAssets.length - 1));
|
||||
}, [photoAssets.length]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!widgetStateRef) return;
|
||||
widgetStateRef.current = {
|
||||
...widgetStateRef.current,
|
||||
immichAlbumCarousel: { currentPhotoIndex, paused },
|
||||
};
|
||||
}, [currentPhotoIndex, paused, widgetStateRef]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!widgetStateRef) return;
|
||||
const clearActions = () => {
|
||||
|
||||
@@ -30,7 +30,10 @@ export default function ImmichServerStatsWidget({
|
||||
if (!stats) return <WidgetEmptyState />;
|
||||
|
||||
const statsContent = (
|
||||
<SimpleGrid cols={displayMode === "advanced" ? 4 : width >= 320 ? 2 : 1} spacing="sm">
|
||||
<SimpleGrid
|
||||
cols={displayMode === "advanced" ? (width >= 720 ? 4 : width >= 360 ? 2 : 1) : width >= 320 ? 2 : 1}
|
||||
spacing="sm"
|
||||
>
|
||||
{options.showUsers && (
|
||||
<StatItem icon={<IconUsers size={20} />} label={t("widget.immich-serverStats.users")} value={stats.userCount} />
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user