Skip to content

Commit ba168a7

Browse files
committed
fix: check if removed tab is considered paused
1 parent fcf5cec commit ba168a7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

background/background.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,14 +508,20 @@ chrome.tabs.onRemoved.addListener(function(tabID) {
508508
delete openedVideos[tabID];
509509
localStorage.setItem('opened', JSON.stringify(openedVideos));
510510
}
511+
for (let tabs of pausedTabs) {
512+
let i = tabs.indexOf(tabID);
513+
if (i > -1) {
514+
tabs.splice(i, 1);
515+
}
516+
}
511517
if (pausedTabs[tabID]) {
512518
setTimeout(function() {
513519
pausedTabs[tabID].forEach(function(tabID) {
514520
// Possible that the tabs that were paused, were closed before
515521
// the new video tab was closed. Check if the tab is still
516522
// around and if it's at the front. Only then play it.
517523
chrome.tabs.get(tabID, function(tab) {
518-
if (!tab || !tab.active) { return; }
524+
if (!tab.active) { return; }
519525
chrome.tabs.executeScript(tabID, { file: 'content/play.js' });
520526
});
521527
});

0 commit comments

Comments
 (0)