Skip to content

Commit

Permalink
allow async fetch immediately via doAsyncFetch()
Browse files Browse the repository at this point in the history
- allow async fetch via doAsyncFetch() on-demand even if behaviors haven't been started (#77)
- bump to 0.6.4
  • Loading branch information
ikreymer committed Aug 13, 2024
1 parent c40c2d2 commit 407da8e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/behaviors.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "browsertrix-behaviors",
"version": "0.6.3",
"version": "0.6.4",
"main": "index.js",
"author": "Webrecorder Software",
"license": "AGPL-3.0-or-later",
Expand Down
8 changes: 4 additions & 4 deletions src/autofetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class AutoFetcher extends BackgroundBehavior {
return url && (url.startsWith("http:") || url.startsWith("https:"));
}

queueUrl(url: string) {
queueUrl(url: string, immediate: boolean = false) {
try {
url = new URL(url, document.baseURI).href;
} catch (e) {
Expand All @@ -110,10 +110,10 @@ export class AutoFetcher extends BackgroundBehavior {

this.urlSet.add(url);

if (!this.running) {
this.waitQueue.push(url);
} else {
if (this.running || immediate) {
this.doFetch(url);
} else {
this.waitQueue.push(url);
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export class BehaviorManager {

doAsyncFetch(url) {
behaviorLog("Queueing Async Fetch Url: " + url);
return this.autofetch.queueUrl(url);
return this.autofetch.queueUrl(url, true);
}

isInTopFrame() {
Expand Down

0 comments on commit 407da8e

Please sign in to comment.