added recent links to dashboard

This commit is contained in:
daniel31x13
2023-10-23 10:45:48 -04:00
parent 697b139493
commit 4252b79586
19 changed files with 461 additions and 53 deletions
+11 -1
View File
@@ -32,7 +32,16 @@ const useLinkStore = create<LinkStore>()((set) => ({
links: [],
}));
set((state) => ({
links: [...state.links, ...data],
// Filter duplicate links by id
links: [...state.links, ...data].reduce(
(links: LinkIncludingShortenedCollectionAndTags[], item) => {
if (!links.some((link) => link.id === item.id)) {
links.push(item);
}
return links;
},
[]
),
}));
},
addLink: async (body) => {
@@ -94,6 +103,7 @@ const useLinkStore = create<LinkStore>()((set) => ({
links: state.links.filter((e) => e.id !== linkId),
}));
useTagStore.getState().setTags();
useCollectionStore.getState().setCollections();
}
return { ok: response.ok, data: data.response };