Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

Commit

Permalink
fix: loading bug (#104)
Browse files Browse the repository at this point in the history
* fix: loading bug

* style: 🤖 prettier code by github action

---------

Co-authored-by: Falcon <falfzz28@gmail.com>
Co-authored-by: Nathan <79507956+CUexter@users.noreply.github.com>
Co-authored-by: CUexter <CUexter@users.noreply.github.com>
  • Loading branch information
4 people authored Apr 13, 2023
1 parent bcd9051 commit 75ac0a7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# [1.10.0](https://github.com/CUexter/Tweet/compare/v1.9.2...v1.10.0) (2023-04-13)


### Features

* like/dislike functionality ([#96](https://github.com/CUexter/Tweet/issues/96)) ([381384d](https://github.com/CUexter/Tweet/commit/381384deb570baa63a30f43bbfcf285792fb0153))
- like/dislike functionality ([#96](https://github.com/CUexter/Tweet/issues/96)) ([381384d](https://github.com/CUexter/Tweet/commit/381384deb570baa63a30f43bbfcf285792fb0153))

## [1.9.2](https://github.com/CUexter/Tweet/compare/v1.9.1...v1.9.2) (2023-04-13)

Expand Down
16 changes: 7 additions & 9 deletions src/components/like.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ import { useSession } from "next-auth/react";
import { useState } from "react";

interface likeProps {
id: {
id: string;
};
id: string;
}

const Like = ({ id }: likeProps) => {
const [isLoading, setIsLoading] = useState(true);

const count = api.like.checkCount.useQuery(
{
tweet_id: id.id,
tweet_id: id,
},
{
onSuccess: () => {
Expand Down Expand Up @@ -50,7 +48,7 @@ const Like = ({ id }: likeProps) => {
);
}

//console.log(uid, id.id);
console.log("id: ", id);

const likeMutation = api.like.like.useMutation();
const unLikeMutation = api.like.unLike.useMutation();
Expand All @@ -59,7 +57,7 @@ const Like = ({ id }: likeProps) => {
const likeQuery = api.like.checkLike.useQuery(
{
user_id: uid,
tweet_id: id.id,
tweet_id: id,
},
{
onSuccess: () => {
Expand All @@ -70,7 +68,7 @@ const Like = ({ id }: likeProps) => {
const dislikeQuery = api.like.checkDislike.useQuery(
{
user_id: uid,
tweet_id: id.id,
tweet_id: id,
},
{
onSuccess: () => {
Expand Down Expand Up @@ -118,7 +116,7 @@ const Like = ({ id }: likeProps) => {
await likeMutation
.mutateAsync({
user_id: uid as string,
tweet_id: id.id,
tweet_id: id,
})
.then(() => {
void likeQuery.refetch();
Expand Down Expand Up @@ -167,7 +165,7 @@ const Like = ({ id }: likeProps) => {
}
await DislikeMutation.mutateAsync({
user_id: uid as string,
tweet_id: id.id,
tweet_id: id,
})
.then(() => {
void dislikeQuery.refetch();
Expand Down
4 changes: 2 additions & 2 deletions src/server/api/routers/like.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const LikeRouter = createTRPCRouter({
});
return result;
}),
checkLike: protectedProcedure
checkLike: publicProcedure
.input(
z.object({
user_id: z.string(),
Expand Down Expand Up @@ -68,7 +68,7 @@ export const LikeRouter = createTRPCRouter({
});
return result;
}),
checkDislike: protectedProcedure
checkDislike: publicProcedure
.input(
z.object({
user_id: z.string(),
Expand Down

1 comment on commit 75ac0a7

@vercel
Copy link

@vercel vercel bot commented on 75ac0a7 Apr 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

tweet – ./

tweet-git-main-cuexter.vercel.app
tweet-rose.vercel.app
tweet-cuexter.vercel.app

Please sign in to comment.