Merge pull request #1979 from HanYaodong/dev_refresh

[Fix] Stop Refresh Animation on Popup When Triggered on Non-YouTube Pages
This commit is contained in:
Ajay Ramachandran
2024-02-29 03:34:45 -05:00
committed by GitHub
2 changed files with 10 additions and 3 deletions

View File

@@ -258,7 +258,12 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
break; break;
case "refreshSegments": case "refreshSegments":
// update video on refresh if videoID invalid // update video on refresh if videoID invalid
if (!getVideoID()) checkVideoIDChange(); if (!getVideoID()) {
checkVideoIDChange().then(() => {
// if still no video ID found, return an empty info to the popup
if (!getVideoID()) chrome.runtime.sendMessage({ message: "infoUpdated" });
});
}
// fetch segments // fetch segments
sponsorsLookup(false); sponsorsLookup(false);

View File

@@ -465,8 +465,8 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
return; return;
} }
//if request is undefined, then the page currently being browsed is not YouTube // if request has no field other than message, then the page currently being browsed is not YouTube
if (request != undefined) { if (request.found != undefined) {
//remove loading text //remove loading text
PageElements.mainControls.style.display = "block"; PageElements.mainControls.style.display = "block";
if (request.onMobileYouTube) PageElements.mainControls.classList.add("hidden"); if (request.onMobileYouTube) PageElements.mainControls.classList.add("hidden");
@@ -490,6 +490,8 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
PageElements.issueReporterImportExport.classList.remove("hidden"); PageElements.issueReporterImportExport.classList.remove("hidden");
} }
} else {
displayNoVideo();
} }
//see if whitelist button should be swapped //see if whitelist button should be swapped