mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
add minimum load time to the UI on toggling a like
This commit is contained in:
1 parent
bb23413533
commit
c2e1f17f3b
2 files changed
+23
-3
No files matched your search
@@ -1,18 +1,33 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { Button } from "@material-ui/core";
|
||||
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";
|
||||
|
||||
const LOADING_TIME = 1250;
|
||||
|
||||
function LikeButton({ tweetId, isLiked }) {
|
||||
const [liked, setLiked] = useState(isLiked);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const handleClick = () => {
|
||||
Nui.send("phone:toggleLike", tweetId);
|
||||
setLiked(!liked);
|
||||
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 /> : <FavoriteBorderIcon />}
|
||||
|
||||
@@ -25,6 +25,11 @@ some of the Material UI primary theme settings */
|
||||
border-bottom-color: #00acee !important;
|
||||
}
|
||||
|
||||
/* override circular progress on the likes button */
|
||||
#twitter-app .MuiCircularProgress-colorPrimary {
|
||||
color: #00acee !important;
|
||||
}
|
||||
|
||||
/*
|
||||
override position of the snackbar so that it appears
|
||||
within the phone rather than on the game UI */
|
||||
|
||||
Reference in new issue
Block a user