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:
erik-sn committed 2020-10-05 21:37:19 -04:00
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;