Fix permission checking
This commit is contained in:
@@ -23,6 +23,7 @@ type LinkStore = {
|
||||
updateLink: (
|
||||
link: LinkIncludingShortenedCollectionAndTags
|
||||
) => Promise<ResponseObject>;
|
||||
updateLinksById: (linkIds: number[], data: Partial<LinkIncludingShortenedCollectionAndTags>) => Promise<ResponseObject>;
|
||||
removeLink: (linkId: number) => Promise<ResponseObject>;
|
||||
deleteLinksById: (linkIds: number[]) => Promise<ResponseObject>;
|
||||
resetLinks: () => void;
|
||||
@@ -127,6 +128,29 @@ const useLinkStore = create<LinkStore>()((set) => ({
|
||||
|
||||
return { ok: response.ok, data: data.response };
|
||||
},
|
||||
updateLinksById: async (linkIds, data) => {
|
||||
const response = await fetch("/api/v1/links/bulk", {
|
||||
body: JSON.stringify({ linkIds, data }),
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
method: "PUT",
|
||||
});
|
||||
|
||||
const responseData = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
set((state) => ({
|
||||
links: state.links.map((link) =>
|
||||
linkIds.includes(link.id) ? { ...link, ...data } : link
|
||||
),
|
||||
}));
|
||||
useTagStore.getState().setTags();
|
||||
useCollectionStore.getState().setCollections();
|
||||
}
|
||||
|
||||
return { ok: response.ok, data: responseData.response };
|
||||
},
|
||||
removeLink: async (linkId) => {
|
||||
const response = await fetch(`/api/v1/links/${linkId}`, {
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user