mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-29 16:31:33 +00:00
fix: always record file views
This commit is contained in:
parent
bca9e76f39
commit
14f4401aef
1 changed files with 4 additions and 4 deletions
|
@ -62,9 +62,8 @@ export default function FileViewer(props: Props) {
|
||||||
: __('Loading');
|
: __('Loading');
|
||||||
|
|
||||||
const previousUri = usePrevious(uri);
|
const previousUri = usePrevious(uri);
|
||||||
const previousIsReadyToPlay = usePrevious(isReadyToPlay);
|
|
||||||
const isNewView = uri && previousUri !== uri && isPlaying;
|
const isNewView = uri && previousUri !== uri && isPlaying;
|
||||||
const wasntReadyButNowItIs = isReadyToPlay && !previousIsReadyToPlay;
|
const [hasRecordedView, setHasRecordedView] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isNewView) {
|
if (isNewView) {
|
||||||
|
@ -73,13 +72,14 @@ export default function FileViewer(props: Props) {
|
||||||
}, [isNewView, uri]);
|
}, [isNewView, uri]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (playTime && isReadyToPlay && wasntReadyButNowItIs) {
|
if (playTime && isReadyToPlay && !hasRecordedView) {
|
||||||
const timeToStart = Date.now() - playTime;
|
const timeToStart = Date.now() - playTime;
|
||||||
triggerAnalyticsView(uri, timeToStart);
|
triggerAnalyticsView(uri, timeToStart);
|
||||||
claimRewards();
|
claimRewards();
|
||||||
setPlayTime(null);
|
setPlayTime(null);
|
||||||
|
setHasRecordedView(false);
|
||||||
}
|
}
|
||||||
}, [setPlayTime, triggerAnalyticsView, isReadyToPlay, wasntReadyButNowItIs, playTime, uri, claimRewards]);
|
}, [setPlayTime, triggerAnalyticsView, isReadyToPlay, hasRecordedView, playTime, uri, claimRewards]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function handleResize() {
|
function handleResize() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue