fix(pages): ensure band list is refreshed on subscribe/unsubscribe
This commit is contained in:
parent
51dfaef149
commit
9378d56242
@ -7,7 +7,10 @@
|
|||||||
const { data: bands } = (await useApiFetch<NonNullable<IBand[]>>("/band/all")) as unknown as { data: Ref<IBand[]> };
|
const { data: bands } = (await useApiFetch<NonNullable<IBand[]>>("/band/all")) as unknown as { data: Ref<IBand[]> };
|
||||||
|
|
||||||
const { data: rd }: { data: any } = useAuth();
|
const { data: rd }: { data: any } = useAuth();
|
||||||
const data = rd as { user: IUser };
|
const refresh = async () => {
|
||||||
|
await useAuth().getSession({ force: true });
|
||||||
|
rd.value = useAuth().data.value;
|
||||||
|
};
|
||||||
|
|
||||||
const hider = subscriptions;
|
const hider = subscriptions;
|
||||||
if (bands.value == null) bands.value = [];
|
if (bands.value == null) bands.value = [];
|
||||||
@ -26,16 +29,39 @@
|
|||||||
</nuxt-link>
|
</nuxt-link>
|
||||||
</a-col>
|
</a-col>
|
||||||
<!-- subscribe... -->
|
<!-- subscribe... -->
|
||||||
<a-col v-if="data && data.user?._id" style="margin-left: auto">
|
<a-col v-if="rd && rd.user?._id" style="margin-left: auto">
|
||||||
<a v-if="!data?.user.subscriptions.bands.includes(item._id)" @click="(e) => hider(bands, item._id, 'subscribe', 'bands')">
|
<a
|
||||||
|
v-if="!rd?.user.subscriptions.bands.includes(item._id)"
|
||||||
|
@click="
|
||||||
|
async (e) => {
|
||||||
|
hider(bands, item._id, 'subscribe', 'bands');
|
||||||
|
await refresh();
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
<icon :istyle="'regular'" name="paper-plane" :size="12" />
|
<icon :istyle="'regular'" name="paper-plane" :size="12" />
|
||||||
</a>
|
</a>
|
||||||
<a v-else @click="(e) => hider(bands, item._id, 'unsubscribe', 'bands')">
|
<a
|
||||||
|
v-else
|
||||||
|
@click="
|
||||||
|
async (e) => {
|
||||||
|
hider(bands, item._id, 'unsubscribe', 'bands');
|
||||||
|
await refresh();
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
<icon :istyle="'regular'" name="x" :size="12" />
|
<icon :istyle="'regular'" name="x" :size="12" />
|
||||||
</a>
|
</a>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col v-if="data?.user._id">
|
<a-col v-if="rd?.user._id">
|
||||||
<a @click="(e) => hider(bands, item._id, 'hide', 'bands')">
|
<a
|
||||||
|
@click="
|
||||||
|
async (e) => {
|
||||||
|
hider(bands, item._id, 'hide', 'bands');
|
||||||
|
await refresh();
|
||||||
|
}
|
||||||
|
"
|
||||||
|
>
|
||||||
<icon :istyle="'regular'" name="eye-slash" :size="12" />
|
<icon :istyle="'regular'" name="eye-slash" :size="12" />
|
||||||
</a>
|
</a>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user