From 51dfaef1493ac44a2a6860e2b40248ac395381f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=99=E2=97=A6=20The=20Tablet=20=E2=9D=80=20GamerGirla?= =?UTF-8?q?ndCo=20=E2=97=A6=E2=9D=A7?= Date: Sat, 30 Dec 2023 16:03:39 -0500 Subject: [PATCH] fix(client-side): fix element being removed for EVERY type of list actoin only splice/remove element if a `hide` action has been executed --- lib/client/listActions.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/client/listActions.ts b/lib/client/listActions.ts index 8c9bee0..01288ae 100644 --- a/lib/client/listActions.ts +++ b/lib/client/listActions.ts @@ -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: {