fix: conflicts resolved

Signed-off-by: Varun Raj <varun@skcript.com>
This commit is contained in:
Varun Raj
2025-01-19 11:17:16 +05:30
3 changed files with 46 additions and 24 deletions
@@ -19,7 +19,7 @@ interface IProps {
export default function MissingLocationAssets({ groupBy }: IProps) {
const { exImmichUrl } = useConfig();
const { startDate, albumId, selectedIds, assets, updateContext } =
const { startDate, albumId, selectedIds, sortOrder, sort, assets, updateContext } =
useMissingLocationContext();
const [loading, setLoading] = useState(false);
@@ -42,26 +42,34 @@ export default function MissingLocationAssets({ groupBy }: IProps) {
};
const images = useMemo(() => {
return assets.map((p) => ({
...p,
src: p.url as string,
original: p.previewUrl as string,
width: p.exifImageWidth as number,
height: p.exifImageHeight as number,
isSelected: selectedIds.includes(p.id),
orientation: 1,
tags: [
{
title: "Immich Link",
value: (
<a href={exImmichUrl + "/photos/" + p.id} target="_blank">
Open in Immich
</a>
),
},
],
}));
}, [assets, selectedIds]);
let sortedAssets: IAsset[];
if (sortOrder === "desc")
sortedAssets = assets.sort((a, b) => new Date(b.dateTimeOriginal).getTime() - new Date(a.dateTimeOriginal).getTime())
else
sortedAssets = assets.sort((a, b) => new Date(a.dateTimeOriginal).getTime() - new Date(b.dateTimeOriginal).getTime());
return sortedAssets.
map((p) => ({
...p,
src: p.url as string,
original: p.previewUrl as string,
width: p.exifImageWidth as number,
height: p.exifImageHeight as number,
isSelected: selectedIds.includes(p.id),
orientation: 1,
tags: [
{
title: "Immich Link",
value: (
<a href={exImmichUrl + "/photos/" + p.id} target="_blank">
Open in Immich
</a>
),
},
],
}));
}, [assets, selectedIds, sortOrder]);
const slides = useMemo(
() =>
+4
View File
@@ -6,6 +6,8 @@ export interface IMissingLocationConfig {
albumId?: string;
selectedIds: string[];
assets: IAsset[];
sort: "fileOriginalDate";
sortOrder: "asc"|"desc";
}
export interface MissingLocationContext extends IMissingLocationConfig {
@@ -17,6 +19,8 @@ const MissingLocationContext = createContext<MissingLocationContext>({
selectedIds: [],
assets: [],
updateContext: () => { },
sort:"fileOriginalDate",
sortOrder: "asc"
});
export default MissingLocationContext;
+13 -3
View File
@@ -12,6 +12,7 @@ import MissingLocationContext, {
import { deleteAssets, updateAssets } from "@/handlers/api/asset.handler";
import { IPlace } from "@/types/common";
import { SortDesc, SortAsc } from "lucide-react";
import { useRouter } from "next/router";
import React, { useMemo } from "react";
import FloatingBar from "@/components/shared/FloatingBar";
@@ -26,6 +27,8 @@ export default function MissingLocations() {
startDate: startDate || undefined,
selectedIds: [],
assets: [],
sort: "fileOriginalDate",
sortOrder: "asc",
});
const selectedAssets = useMemo(() => config.assets.filter((a) => config.selectedIds.includes(a.id)), [config.assets, config.selectedIds]);
@@ -59,6 +62,9 @@ export default function MissingLocations() {
selectedIds: [],
});
}
const handleChange = (e: { sortOrder: "asc" | "desc" }) => {
setConfig({ ...config, sortOrder: e.sortOrder });
}
return (
<PageLayout className="!p-0 !mb-0 relative">
@@ -85,7 +91,11 @@ export default function MissingLocations() {
<SelectItem value="date">Date</SelectItem>
</SelectContent>
</Select>
<div>
<Button variant="default" size="sm" onClick={() => handleChange({ sortOrder: config.sortOrder === "asc" ? "desc" : "asc" })}>
{config.sortOrder === "asc" ? <SortAsc size={16} /> : <SortDesc size={16} />}
</Button>
</div>
</div>
}
/>
@@ -139,8 +149,8 @@ export default function MissingLocations() {
<AssetOffsetDialog assets={selectedAssets} onComplete={handleOffsetComplete} />
<div className="h-[10px] w-[1px] bg-zinc-500 dark:bg-zinc-600"></div>
<AlertDialog
title="Delete the selected assets?"
description="This action will delete the selected assets and cannot be undone."
title="Delete the selected assets?"
description="This action will delete the selected assets and cannot be undone."
onConfirm={handleDelete}
disabled={config.selectedIds.length === 0}
>