Commit 566da7ac authored by Mark Harding's avatar Mark Harding

(fix): check visibility needs to be bound

parent cef7c142
No related merge requests found
Pipeline #85044874 passed with stages
in 46 minutes and 53 seconds
......@@ -61,10 +61,9 @@ export class ActivityAnalyticsOnViewService implements OnDestroy {
}
});
this.scroll$ = this.scroll.listenForView().subscribe(this.checkVisibility);
// Do a check for the initial posts
this.checkVisibility();
this.scroll$ = this.scroll.listenForView().subscribe(() => {
this.checkVisibility();
});
}
checkVisibility() {
......
......@@ -239,6 +239,8 @@ export class Activity implements OnInit {
this.activity.time_created || Math.floor(Date.now() / 1000);
this.allowComments = this.activity.allow_comments;
this.activityAnalyticsOnViewService.checkVisibility(); // perform check
}
getOwnerIconTime() {
......
......@@ -86,12 +86,6 @@ export class MediaViewComponent implements OnInit, OnDestroy {
}
}
);
this.analyticsService.recordView(this.entity, {
position: -1,
source: 'single',
medium: 'single',
});
}
ngOnDestroy() {
......@@ -133,6 +127,8 @@ export class MediaViewComponent implements OnInit, OnDestroy {
}
}
this.recordAnalytics();
this.detectChanges();
})
.catch(e => {
......@@ -224,6 +220,14 @@ export class MediaViewComponent implements OnInit, OnDestroy {
return this.entity['comments:count'] >= 1;
}
recordAnalytics() {
this.analyticsService.recordView(this.entity, {
position: -1,
source: 'single',
medium: 'single',
});
}
private detectChanges() {
this.cd.markForCheck();
this.cd.detectChanges();
......
......@@ -73,6 +73,9 @@ export class AnalyticsService {
medium: string;
}
) {
await this.client.post('api/v2/analytics/entity/' + entity.guid, meta);
await this.client.post(
'api/v2/analytics/views/entity/' + entity.guid,
meta
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment