Fixed issue where some some videos would send many requests to SponsorBlock when only one was needed

pull/443/head
Isaac Abadi 4 years ago
parent 11284cb1b3
commit 9e60d9fe3e

@ -17,10 +17,16 @@ export class SkipAdButtonComponent implements OnInit {
sponsor_block_cache = {};
show_skip_ad_button = false;
skip_ad_button_check_interval = null;
constructor(private postsService: PostsService) { }
ngOnInit(): void {
setInterval(() => this.skipAdButtonCheck(), 500);
this.skip_ad_button_check_interval = setInterval(() => this.skipAdButtonCheck(), 500);
}
ngOnDestroy(): void {
clearInterval(this.skip_ad_button_check_interval);
}
checkSponsorBlock(video_to_check) {
@ -45,6 +51,8 @@ export class SkipAdButtonComponent implements OnInit {
const found_data = res['find'](data => data['videoID'] === video_id);
if (found_data) {
this.sponsor_block_cache[video_to_check.url] = found_data;
} else {
this.sponsor_block_cache[video_to_check.url] = null;
}
}, err => {
// likely doesn't exist

Loading…
Cancel
Save