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