show connectionError string if status is not 404
This commit is contained in:
Michael C 2022-06-24 01:21:19 -04:00
parent 6b4da25847
commit b92132bf47
No known key found for this signature in database
GPG key ID: FFB04FB3B878B7B4
3 changed files with 17 additions and 6 deletions

View file

@ -65,8 +65,8 @@ const videosWithEventListeners: HTMLVideoElement[] = [];
const controlsWithEventListeners: HTMLElement[] = []
// This misleading variable name will be fixed soon
let onInvidious;
let onMobileYouTube;
let onInvidious: boolean;
let onMobileYouTube: boolean;
//the video id of the last preview bar update
let lastPreviewBarUpdate;
@ -117,6 +117,9 @@ let submissionNotice: SubmissionNotice = null;
// If there is an advert playing (or about to be played), this is true
let isAdPlaying = false;
// last response status
let lastResponseStatus: number;
// Contains all of the functions and variables needed by the skip notice
const skipNoticeContentContainer: ContentContainer = () => ({
vote,
@ -163,6 +166,7 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
//send the sponsor times along with if it's found
sendResponse({
found: sponsorDataFound,
status: lastResponseStatus,
sponsorTimes: sponsorTimes,
onMobileYouTube
});
@ -204,6 +208,7 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
case "refreshSegments":
sponsorsLookup(false).then(() => sendResponse({
found: sponsorDataFound,
status: lastResponseStatus,
sponsorTimes: sponsorTimes,
onMobileYouTube
}));
@ -904,8 +909,11 @@ async function sponsorsLookup(keepOldSubmissions = true) {
//otherwise the listener can handle it
updatePreviewBar();
}
} else if (response?.status === 404) {
retryFetch();
} else {
lastResponseStatus = response?.status;
if (lastResponseStatus === 404) {
retryFetch();
}
}
if (Config.config.isVip) {

View file

@ -63,6 +63,7 @@ export type Message = BaseMessage & (DefaultMessage | BoolValueMessage | IsInfoF
export interface IsInfoFoundMessageResponse {
found: boolean;
status: number;
sponsorTimes: SponsorTime[];
onMobileYouTube: boolean;
}
@ -89,7 +90,7 @@ export type MessageResponse =
| GetChannelIDResponse
| SponsorStartResponse
| IsChannelWhitelistedResponse
| Record<string, never>
| Record<never, never> // empty object response {}
| VoteResponse;
export interface VoteResponse {

View file

@ -367,8 +367,10 @@ async function runThePopup(messageListener?: MessageListener): Promise<void> {
PageElements.videoFound.innerHTML = chrome.i18n.getMessage("sponsorFound");
displayDownloadedSponsorTimes(request);
} else {
} else if (request.status == 404) {
PageElements.videoFound.innerHTML = chrome.i18n.getMessage("sponsor404");
} else {
PageElements.videoFound.innerHTML = chrome.i18n.getMessage("connectionError") + request.status;
}
}