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
@ -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") => {
|
||||
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),
|
||||
values!.findIndex((a) => a._id == id || a == id),
|
||||
1,
|
||||
);
|
||||
if (action == "hide") {
|
||||
useApiFetch(`${base}/${action}`, {
|
||||
body: {
|
||||
push: {
|
||||
|
Loading…
Reference in New Issue
Block a user