mirror of
https://github.com/antebudimir/feishin.git
synced 2025-12-31 10:03:33 +00:00
add initial rating when a single item is provided in context menu
This commit is contained in:
parent
751ad55d02
commit
dc03a432fe
1 changed files with 10 additions and 6 deletions
|
|
@ -103,12 +103,6 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
|||
const { t } = useTranslation();
|
||||
const [opened, setOpened] = useState(false);
|
||||
|
||||
const [rating, setRating] = useState<number>(0);
|
||||
|
||||
useEffect(() => {
|
||||
setRating(0);
|
||||
}, [opened]);
|
||||
|
||||
const clickOutsideRef = useClickOutside(() => setOpened(false), ['mousedown', 'touchstart']);
|
||||
|
||||
const viewport = useViewportSize();
|
||||
|
|
@ -126,6 +120,16 @@ export const ContextMenuProvider = ({ children }: ContextMenuProviderProps) => {
|
|||
yPos: 0,
|
||||
});
|
||||
|
||||
const [rating, setRating] = useState<number>(0);
|
||||
|
||||
useEffect(() => {
|
||||
if (opened && ctx.data.length === 1) {
|
||||
setRating(ctx.data[0].userRating ?? 0);
|
||||
} else {
|
||||
setRating(0);
|
||||
}
|
||||
}, [ctx.data, opened]);
|
||||
|
||||
const handlePlayQueueAdd = usePlayQueueAdd();
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue