fix(client-side): fix element being removed for EVERY type of list actoin

only splice/remove element if a `hide` action has been executed
This commit is contained in:
parent 3a8fd82dae
commit 51dfaef149
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

@ -1,5 +1,6 @@
import { ListGridType } from "ant-design-vue/es/list"; import { ListGridType } from "ant-design-vue/es/list";
import { FavPayload, HidePayload, SubPayload } from "./types/form/favSub"; import { FavPayload, HidePayload, SubPayload } from "./types/form/favSub";
import { useRoute, useRouter } from "#app";
const base = `/user/me`; const base = `/user/me`;
@ -21,12 +22,20 @@ export const favourites = (values: (any & { _id: number })[], id: number, remove
}); });
}; };
export const subscriptions = (values: (any & { _id: number })[], id: number, action: "hide" | "subscribe" | "unsubscribe", type: "bands" | "authors") => { export const subscriptions = (
values?.splice( values: ((any & { _id: number }) | number)[],
values!.findIndex((a) => a._id == id), id: number,
1, action: "hide" | "subscribe" | "unsubscribe",
); type: "bands" | "authors",
) => {
const rtr = useRouter();
console.log("subby", values);
if (action == "hide") { if (action == "hide") {
values?.splice(
values!.findIndex((a) => a._id == id || a == id),
1,
);
useApiFetch(`${base}/${action}`, { useApiFetch(`${base}/${action}`, {
body: { body: {
push: { push: {