Skip to content

Commit 96ff15c

Browse files
committed
fix: remove sleep and move retry limits to settings
1 parent c795851 commit 96ff15c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

injected/src/features/autofill-import.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -590,15 +590,19 @@ export default class AutofillImport extends ActionExecutorBase {
590590

591591
/** Bookmark import code */
592592
async downloadData() {
593-
// sleep for a second, sometimes download link is not yet available
594-
await new Promise((resolve) => setTimeout(resolve, 2000));
595-
596593
const userIdElement = await this.runWithRetry(() => document.querySelector(this.bookmarkImportSelectorSettings.userIdLink));
597594
const userId = userIdElement?.getAttribute('href')?.split('&user=')[1];
598595

599596
// Poll forever until the download link is available,
600597
// Android is the one that timesout anyway and closes the whole tab if this doesn't complete
601-
await this.runWithRetry(() => document.querySelector(`a[href="./manage/archive/${this.#exportId}"]`), Infinity, 1000, 'linear');
598+
const downloadRetryLimit = this.getFeatureSetting('downloadRetryLimit') ?? Infinity;
599+
const downloadRetryInterval = this.getFeatureSetting('downloadRetryInterval') ?? 1000;
600+
await this.runWithRetry(
601+
() => document.querySelector(`a[href="./manage/archive/${this.#exportId}"]`),
602+
downloadRetryLimit,
603+
downloadRetryInterval,
604+
'linear',
605+
);
602606

603607
if (userId != null && this.#exportId != null) {
604608
const downloadURL = `${TAKEOUT_DOWNLOAD_URL_BASE}?j=${this.#exportId}&i=0&user=${userId}`;

0 commit comments

Comments
 (0)