Round Video: Mark as read when played (#5705)
This commit is contained in:
parent
cbd0d47aa5
commit
8665905a05
@ -181,13 +181,11 @@
|
||||
align-items: flex-end;
|
||||
|
||||
&.unread::after {
|
||||
content: "";
|
||||
position: relative;
|
||||
margin: 0 0 0.375rem 0.25rem;
|
||||
width: 0.4375rem;
|
||||
height: 0.4375rem;
|
||||
border-radius: 50%;
|
||||
background-color: var(--accent-color);
|
||||
content: "•";
|
||||
font-size: 2rem;
|
||||
line-height: 1.3125rem;
|
||||
color: var(--accent-color);
|
||||
margin-inline-start: 0.125rem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -242,10 +242,10 @@ const Audio: FC<OwnProps> = ({
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (onReadMedia && isMediaUnread && (isPlaying || isDownloading)) {
|
||||
if (onReadMedia && isMediaUnread && isPlaying) {
|
||||
onReadMedia();
|
||||
}
|
||||
}, [isPlaying, isMediaUnread, onReadMedia, isDownloading]);
|
||||
}, [isPlaying, isMediaUnread, onReadMedia]);
|
||||
|
||||
const handleDownloadClick = useLastCallback(() => {
|
||||
if (isDownloading) {
|
||||
|
||||
@ -94,4 +94,10 @@
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
.unread::after {
|
||||
content: "•";
|
||||
font-size: 2rem;
|
||||
margin-inline-start: 0.125rem;
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,6 +91,7 @@ const RoundVideo: FC<OwnProps> = ({
|
||||
const isIntersecting = useIsIntersecting(ref, observeIntersection);
|
||||
|
||||
const video = message.content.video!;
|
||||
const isMediaUnread = message.isMediaUnread;
|
||||
|
||||
const [isLoadAllowed, setIsLoadAllowed] = useState(canAutoLoad);
|
||||
const shouldLoad = Boolean(isLoadAllowed && isIntersecting);
|
||||
@ -219,6 +220,12 @@ const RoundVideo: FC<OwnProps> = ({
|
||||
togglePlaying();
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (onReadMedia && isMediaUnread && isActivated) {
|
||||
onReadMedia();
|
||||
}
|
||||
}, [isActivated, isMediaUnread, onReadMedia]);
|
||||
|
||||
const handleTimeUpdate = useLastCallback((e: React.UIEvent<HTMLVideoElement>) => {
|
||||
const playerEl = e.currentTarget;
|
||||
setProgress(playerEl.currentTime / playerEl.duration);
|
||||
@ -322,7 +329,11 @@ const RoundVideo: FC<OwnProps> = ({
|
||||
<Icon name="download" />
|
||||
)}
|
||||
{!isInOneTimeModal && (
|
||||
<div className="message-media-duration">
|
||||
<div
|
||||
className={buildClassName(
|
||||
'message-media-duration', isMediaUnread && 'unread',
|
||||
)}
|
||||
>
|
||||
{isActivated ? formatMediaDuration(playerRef.current!.currentTime) : formatMediaDuration(video.duration)}
|
||||
{(!isActivated || playerRef.current!.paused) && <Icon name="muted" />}
|
||||
</div>
|
||||
|
||||
@ -788,7 +788,7 @@
|
||||
.message-media-duration .icon-muted {
|
||||
vertical-align: -0.1875rem;
|
||||
margin-left: 0.375rem;
|
||||
font-size: 1.0625rem;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.message-media-duration .playback-failed {
|
||||
|
||||
@ -665,8 +665,8 @@ export function getIsDownloading(activeDownloads: ActiveDownloads, media: Downlo
|
||||
}
|
||||
|
||||
export function getTimestampableMedia(message: MediaContainer) {
|
||||
return getMessageVideo(message)
|
||||
|| getMessageWebPageVideo(message)
|
||||
const video = getMessageVideo(message) || getMessageWebPageVideo(message);
|
||||
return (video && !video.isRound && !video.isGif ? video : undefined)
|
||||
|| getMessageAudio(message)
|
||||
|| getMessageVoice(message);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user