store response status 200

This commit is contained in:
Michael C 2022-06-24 10:49:57 -04:00
parent b92132bf47
commit 7cc0847db1
No known key found for this signature in database
GPG key ID: FFB04FB3B878B7B4
2 changed files with 4 additions and 3 deletions

View file

@ -833,7 +833,6 @@ async function sponsorsLookup(keepOldSubmissions = true) {
const hashParams = getHashParams(); const hashParams = getHashParams();
if (hashParams.requiredSegment) extraRequestData.requiredSegment = hashParams.requiredSegment; if (hashParams.requiredSegment) extraRequestData.requiredSegment = hashParams.requiredSegment;
// Check for hashPrefix setting
const hashPrefix = (await utils.getHash(sponsorVideoID, 1)).slice(0, 4) as VideoID & HashedValue; const hashPrefix = (await utils.getHash(sponsorVideoID, 1)).slice(0, 4) as VideoID & HashedValue;
const response = await utils.asyncRequestToServer('GET', "/api/skipSegments/" + hashPrefix, { const response = await utils.asyncRequestToServer('GET', "/api/skipSegments/" + hashPrefix, {
categories, categories,
@ -842,6 +841,9 @@ async function sponsorsLookup(keepOldSubmissions = true) {
...extraRequestData ...extraRequestData
}); });
// store last response status
lastResponseStatus = response?.status;
if (response?.ok) { if (response?.ok) {
const recievedSegments: SponsorTime[] = JSON.parse(response.responseText) const recievedSegments: SponsorTime[] = JSON.parse(response.responseText)
?.filter((video) => video.videoID === sponsorVideoID) ?.filter((video) => video.videoID === sponsorVideoID)
@ -910,7 +912,6 @@ async function sponsorsLookup(keepOldSubmissions = true) {
updatePreviewBar(); updatePreviewBar();
} }
} else { } else {
lastResponseStatus = response?.status;
if (lastResponseStatus === 404) { if (lastResponseStatus === 404) {
retryFetch(); retryFetch();
} }

View file

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