Skip to content

Commit

Permalink
Add header to bypass server side cache
Browse files Browse the repository at this point in the history
  • Loading branch information
hanydd committed Jun 14, 2024
1 parent 3e004d4 commit 4557063
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion maze-utils
10 changes: 5 additions & 5 deletions src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ function messageListener(request: Message, sender: unknown, sendResponse: (respo
// it will assume the page is not a video page and stop the refresh animation
sendResponse({ hasVideo: getVideoID() != null });
// fetch segments
sponsorsLookup(false);
sponsorsLookup(false, true);

break;
case "unskip":
Expand Down Expand Up @@ -971,14 +971,14 @@ function setupCategoryPill() {
categoryPill.attachToPage(voteAsync);
}

async function sponsorsLookup(keepOldSubmissions = true) {
async function sponsorsLookup(keepOldSubmissions = true, ignoreServerCache = false) {
if (lookupWaiting) return;
//there is still no video here
if (!getVideo()) {
lookupWaiting = true;
setTimeout(() => {
lookupWaiting = false;
sponsorsLookup()
sponsorsLookup(keepOldSubmissions, ignoreServerCache)
}, 100);
return;
}
Expand All @@ -995,7 +995,7 @@ async function sponsorsLookup(keepOldSubmissions = true) {
actionTypes: getEnabledActionTypes(),
userAgent: `${chrome.runtime.id}`,
...extraRequestData
});
}, ignoreServerCache);

// store last response status
lastResponseStatus = response?.status;
Expand Down Expand Up @@ -1810,7 +1810,7 @@ function startOrEndTimingNewSegment() {
Config.forceLocalUpdate("unsubmittedSegments");

// Make sure they know if someone has already submitted something it while they were watching
sponsorsLookup();
sponsorsLookup(true, true);

updateEditButtonsOnPlayer();
updateSponsorTimesSubmitting(false);
Expand Down
8 changes: 4 additions & 4 deletions src/utils/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { FetchResponse, sendRequestToCustomServer } from "../../maze-utils/src/b
* @param address The address to add to the SponsorBlock server address
* @param callback
*/
export function asyncRequestToCustomServer(type: string, url: string, data = {}): Promise<FetchResponse> {
return sendRequestToCustomServer(type, url, data);
export function asyncRequestToCustomServer(type: string, url: string, data = {}, ignoreServerCache = false): Promise<FetchResponse> {
return sendRequestToCustomServer(type, url, data, ignoreServerCache);
}

/**
Expand All @@ -20,10 +20,10 @@ export function asyncRequestToCustomServer(type: string, url: string, data = {})
* @param address The address to add to the SponsorBlock server address
* @param callback
*/
export async function asyncRequestToServer(type: string, address: string, data = {}): Promise<FetchResponse> {
export async function asyncRequestToServer(type: string, address: string, data = {}, ignoreServerCache = false): Promise<FetchResponse> {
const serverAddress = Config.config.testingServer ? CompileConfig.testingServerAddress : Config.config.serverAddress;

return await (asyncRequestToCustomServer(type, serverAddress + address, data));
return await (asyncRequestToCustomServer(type, serverAddress + address, data, ignoreServerCache));
}

/**
Expand Down

0 comments on commit 4557063

Please sign in to comment.