mirror of
https://github.com/jeffvli/feishin.git
synced 2026-07-15 15:10:01 +02:00
additional type fix for album group
This commit is contained in:
@@ -23,10 +23,10 @@ const ALBUM_GROUP_ITEM_LABELS: Array<[AlbumGroupItem, string]> = [
|
|||||||
[AlbumGroupItem.SIZE, 'table.column.size'],
|
[AlbumGroupItem.SIZE, 'table.column.size'],
|
||||||
];
|
];
|
||||||
|
|
||||||
const mergeItems = (
|
const mergeItems = <K extends string, T extends SortableItem<K>>(
|
||||||
items: SortableItem<AlbumGroupItem>[],
|
items: T[],
|
||||||
itemLabels: Array<[string, string]>,
|
itemLabels: Array<[K, string]>,
|
||||||
): SortableItem<AlbumGroupItem>[] => {
|
): T[] => {
|
||||||
const allItemIds = itemLabels.map(([key]) => key);
|
const allItemIds = itemLabels.map(([key]) => key);
|
||||||
|
|
||||||
const missingItemIds = allItemIds.filter((id) => !items.some((item) => item.id === id));
|
const missingItemIds = allItemIds.filter((id) => !items.some((item) => item.id === id));
|
||||||
@@ -36,7 +36,7 @@ const mergeItems = (
|
|||||||
...(missingItemIds.map((id) => ({
|
...(missingItemIds.map((id) => ({
|
||||||
disabled: true,
|
disabled: true,
|
||||||
id,
|
id,
|
||||||
})) as SortableItem<AlbumGroupItem>[]),
|
})) as T[]),
|
||||||
];
|
];
|
||||||
|
|
||||||
const uniqueMerged = merged.filter(
|
const uniqueMerged = merged.filter(
|
||||||
@@ -52,7 +52,8 @@ export const AlbumGroupMetadataConfig = memo(() => {
|
|||||||
const { setAlbumGroupItems } = useSettingsStoreActions();
|
const { setAlbumGroupItems } = useSettingsStoreActions();
|
||||||
|
|
||||||
const items = useMemo(
|
const items = useMemo(
|
||||||
() => mergeItems(albumGroupItems, ALBUM_GROUP_ITEM_LABELS),
|
() =>
|
||||||
|
mergeItems(albumGroupItems as SortableItem<AlbumGroupItem>[], ALBUM_GROUP_ITEM_LABELS),
|
||||||
[albumGroupItems],
|
[albumGroupItems],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user