mirror of
https://github.com/emailerfacu-spec/minix-front.git
synced 2026-04-01 13:10:44 -03:00
Actualizado el boton de like
This commit is contained in:
@@ -77,7 +77,11 @@
|
||||
|
||||
async function likeHandler() {
|
||||
cargandoLike = true;
|
||||
let { message, ok } = await likePost(post);
|
||||
//para que se vea el spinner
|
||||
let [{ message, ok }] = await Promise.all([
|
||||
likePost(post),
|
||||
new Promise((resolve) => setTimeout(resolve, 300))
|
||||
]);
|
||||
if (ok) {
|
||||
if (post.isLiked) {
|
||||
post.likesCount--;
|
||||
@@ -159,14 +163,18 @@
|
||||
<div class="-mt-2 flex items-center justify-between gap-2 text-xs text-muted-foreground">
|
||||
<Button
|
||||
variant="ghost"
|
||||
disabled={!$sesionStore?.accessToken}
|
||||
disabled={!$sesionStore?.accessToken || cargandoLike}
|
||||
class={`${post.isLiked ? 'bg-blue-500/30' : 'bg-accent'} flex items-center gap-2 rounded-full p-3 text-lg`}
|
||||
onclick={() => likeHandler()}
|
||||
>
|
||||
<p>
|
||||
{post.likesCount}
|
||||
</p>
|
||||
<ThumbsUp />
|
||||
{#if cargandoLike}
|
||||
<Spinner />
|
||||
{:else}
|
||||
<ThumbsUp />
|
||||
{/if}
|
||||
</Button>
|
||||
<Button variant="ghost" class="flex items-center gap-2 rounded-full bg-accent p-3 text-lg">
|
||||
<p>
|
||||
|
||||
Reference in New Issue
Block a user