Clear segment list & show loading animation in popup on video change

also removed the creatingSegment variable - results in "Start/End Segment Now" correctly updating when using buttons on the controls panel instead
also the "refreshSegments" message no longer sends a response, as we send an update manually now
This commit is contained in:
mini-bomba
2022-10-11 17:15:11 +02:00
parent c8cbd893f7
commit b7a574fc16
4 changed files with 57 additions and 21 deletions

View File

@@ -215,7 +215,6 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
case "getVideoID":
sendResponse({
videoID: sponsorVideoID,
creatingSegment: isSegmentCreationInProgress(),
});
break;
@@ -243,15 +242,9 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
// update video on refresh if videoID invalid
if (!sponsorVideoID) videoIDChange(getYouTubeVideoID(document));
// fetch segments
sponsorsLookup(false).then(() => sendResponse({
found: sponsorDataFound,
status: lastResponseStatus,
sponsorTimes: sponsorTimes,
time: video.currentTime,
onMobileYouTube
}));
sponsorsLookup(false);
return true;
break;
case "unskip":
unskipSponsorTime(sponsorTimes.find((segment) => segment.UUID === request.UUID), null, true);
break;
@@ -438,6 +431,13 @@ async function videoIDChange(id: string): Promise<void> {
}
}
// Notify the popup about the video change
chrome.runtime.sendMessage({
message: "videoChanged",
videoID: sponsorVideoID,
whitelisted: channelWhitelisted
});
sponsorsLookup();
// Make sure all player buttons are properly added