fix: endsAt not updating correctly
This commit is contained in:
2 files changed
+29
-6
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { Typography } from "@mui/material";
|
||||
import React from "react";
|
||||
import { useShallow } from "zustand/shallow";
|
||||
import { endsAt } from "@/utils/date/time";
|
||||
import { usePlaybackStore } from "@/utils/store/playback";
|
||||
|
||||
const EndsAtDisplay = () => {
|
||||
const { currentTime, itemDuration } = usePlaybackStore(
|
||||
useShallow((state) => ({
|
||||
currentTime: state.playerState.currentTime,
|
||||
itemDuration: state.metadata.itemDuration,
|
||||
})),
|
||||
);
|
||||
|
||||
if (!itemDuration) return null;
|
||||
|
||||
const remaining = itemDuration - (currentTime ?? 0);
|
||||
|
||||
return (
|
||||
<Typography variant="subtitle1">
|
||||
{endsAt(remaining)}
|
||||
</Typography>
|
||||
);
|
||||
};
|
||||
|
||||
export default EndsAtDisplay;
|
||||
Reference in new issue
Block a user