mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
initial likes implementation
This adds the initial likes implementation. We take an approach of just toggling the like in the database rather than adding a loading mechanic and waiting on the UI.
This commit is contained in:
1 parent
7e690d0e92
commit
bb23413533
6 files changed
+149
-12
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { Button } from "@material-ui/core";
|
||||
import FavoriteBorderIcon from "@material-ui/icons/FavoriteBorder";
|
||||
import FavoriteIcon from "@material-ui/icons/Favorite";
|
||||
|
||||
import Nui from "../../../../os/nui-events/utils/Nui";
|
||||
|
||||
function LikeButton({ tweetId, isLiked }) {
|
||||
const [liked, setLiked] = useState(isLiked);
|
||||
|
||||
const handleClick = () => {
|
||||
Nui.send("phone:toggleLike", tweetId);
|
||||
setLiked(!liked);
|
||||
};
|
||||
|
||||
return (
|
||||
<Button onClick={handleClick}>
|
||||
{liked ? <FavoriteIcon /> : <FavoriteBorderIcon />}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
export default LikeButton;
|
||||
Reference in new issue
Block a user