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() {
|
async function likeHandler() {
|
||||||
cargandoLike = true;
|
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 (ok) {
|
||||||
if (post.isLiked) {
|
if (post.isLiked) {
|
||||||
post.likesCount--;
|
post.likesCount--;
|
||||||
@@ -159,14 +163,18 @@
|
|||||||
<div class="-mt-2 flex items-center justify-between gap-2 text-xs text-muted-foreground">
|
<div class="-mt-2 flex items-center justify-between gap-2 text-xs text-muted-foreground">
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
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`}
|
class={`${post.isLiked ? 'bg-blue-500/30' : 'bg-accent'} flex items-center gap-2 rounded-full p-3 text-lg`}
|
||||||
onclick={() => likeHandler()}
|
onclick={() => likeHandler()}
|
||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
{post.likesCount}
|
{post.likesCount}
|
||||||
</p>
|
</p>
|
||||||
<ThumbsUp />
|
{#if cargandoLike}
|
||||||
|
<Spinner />
|
||||||
|
{:else}
|
||||||
|
<ThumbsUp />
|
||||||
|
{/if}
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="ghost" class="flex items-center gap-2 rounded-full bg-accent p-3 text-lg">
|
<Button variant="ghost" class="flex items-center gap-2 rounded-full bg-accent p-3 text-lg">
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
Reference in New Issue
Block a user