mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 22:16:54 +00:00
* chore(scripts/twitter): Refactored twitter to use event enums * chore(scripts/marketplace): Refactored marketplace to use event enums * chore(scripts/messages): Refactored messages to use event enums * chore(scripts/contacts): Refactored contacts to use event enums * chore(scripts/calls): Refactored calls to use event enums * chore(scripts/notes): Refactored notes to use event enums * chore(scripts/photos): Refactored photos to use event enums * chore(scripts/bank): Refactored bank to use event enums * chore(scripts/phone): Refactored phone to use event enums * chore(events): Removed old events object * refactor(phone/nui-events): Attached NUI events to respective enum * tweak(event-enums): Added npwd prefix to all events * tweak(phone/serve): Added craco to override CRA without eject Also bumped react-scripts to 4.0.1, with seemingly no issues * fix(typings/twitter): Fixed method enums for twitter
40 lines
1019 B
TypeScript
40 lines
1019 B
TypeScript
import React, { useState } from 'react';
|
|
import { Button, CircularProgress } 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';
|
|
import { TwitterEvents } from '../../../../../../typings/twitter';
|
|
|
|
const LOADING_TIME = 1250;
|
|
|
|
function LikeButton({ tweetId, isLiked }) {
|
|
const [liked, setLiked] = useState(isLiked);
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const handleClick = () => {
|
|
Nui.send(TwitterEvents.TOGGLE_LIKE, tweetId);
|
|
setLoading(true);
|
|
window.setTimeout(() => {
|
|
setLiked(!liked);
|
|
setLoading(false);
|
|
}, LOADING_TIME);
|
|
};
|
|
|
|
if (loading) {
|
|
return (
|
|
<Button disabled>
|
|
<CircularProgress size={22} />
|
|
</Button>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Button onClick={handleClick}>
|
|
{liked ? <FavoriteIcon color="primary" /> : <FavoriteBorderIcon />}
|
|
</Button>
|
|
);
|
|
}
|
|
|
|
export default LikeButton;
|