mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-16 13:40:24 +02:00
Add favorite handler to grid cards
This commit is contained in:
@@ -9,6 +9,7 @@ export interface AlbumListDataState {
|
||||
export interface AlbumListDataSlice extends AlbumListDataState {
|
||||
actions: {
|
||||
setItemData: (data: any[]) => void;
|
||||
setItemDataById: (id: string, data: any) => void;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -21,6 +22,13 @@ export const useAlbumListDataStore = create<AlbumListDataSlice>()(
|
||||
state.itemData = data;
|
||||
});
|
||||
},
|
||||
setItemDataById: (id, data) => {
|
||||
set((state) => {
|
||||
const index = state.itemData.findIndex((item) => item?.id === id);
|
||||
if (index === -1) return;
|
||||
state.itemData[index] = { ...state.itemData[index], ...data };
|
||||
});
|
||||
},
|
||||
},
|
||||
itemData: [],
|
||||
})),
|
||||
@@ -34,3 +42,6 @@ export const useAlbumListItemData = () =>
|
||||
useAlbumListDataStore((state) => {
|
||||
return { itemData: state.itemData, setItemData: state.actions.setItemData };
|
||||
});
|
||||
|
||||
export const useSetAlbumListItemDataById = () =>
|
||||
useAlbumListDataStore((state) => state.actions.setItemDataById);
|
||||
|
||||
Reference in New Issue
Block a user