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 { FavPayload, HidePayload, SubPayload } from "./types/form/favSub";
import { useRoute, useRouter } from "#app";
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") => {
values?.splice(
values!.findIndex((a) => a._id == id),
1,
);
export const subscriptions = (
values: ((any & { _id: number }) | number)[],
id: number,
action: "hide" | "subscribe" | "unsubscribe",
type: "bands" | "authors",
) => {
const rtr = useRouter();
console.log("subby", values);
if (action == "hide") {
values?.splice(
values!.findIndex((a) => a._id == id || a == id),
1,
);
useApiFetch(`${base}/${action}`, {
body: {
push: {