fix(realdebrid): respect dismissed login windows

Remember a user-dismissed browser login per Real-Debrid web account so queued and repeated unrestrict attempts cannot reopen it. Clear the suppression only after explicit login or successful authentication, and close successful login windows without treating them as user cancellations.
This commit is contained in:
Sucukdeluxe
2026-08-15 21:48:37 +02:00
parent 31560cfbe0
commit 935f39d7db
2 changed files with 41 additions and 8 deletions
+17 -8
View File
@@ -135,6 +135,8 @@ export class RealDebridWebFallback {
private onClosed?: () => void;
private interactiveLoginDismissed = false;
private persistentPartition: string;
private transientPartition: string;
@@ -176,7 +178,8 @@ export class RealDebridWebFallback {
public async openLoginWindow(): Promise<void> {
this.throwIfDisposed();
const window = await this.ensureLoginWindow();
this.interactiveLoginDismissed = false;
const window = await this.ensureLoginWindow();
if (window.isMinimized()) {
window.restore();
}
@@ -340,6 +343,7 @@ export class RealDebridWebFallback {
let closingTokenProbe: Promise<void> = Promise.resolve();
window.on("close", () => {
if (!this.programmaticClosures.has(window)) {
this.interactiveLoginDismissed = true;
closingTokenProbe = this.primeTokenFromWindow(window, windowGeneration);
}
});
@@ -372,6 +376,7 @@ export class RealDebridWebFallback {
const changed = token !== this.cachedToken;
this.cachedToken = token;
this.cachedTokenAt = Date.now();
this.interactiveLoginDismissed = false;
if (changed && this.onAuthenticated) {
void Promise.resolve().then(() => this.onAuthenticated?.());
}
@@ -581,8 +586,11 @@ export class RealDebridWebFallback {
throw new Error("Real-Debrid Web: Unrestrict fehlgeschlagen");
}
private async waitForLoginAndGenerate(link: string, signal?: AbortSignal): Promise<UnrestrictedLink | null> {
const window = await this.ensureLoginWindow();
private async waitForLoginAndGenerate(link: string, signal?: AbortSignal): Promise<UnrestrictedLink | null> {
if (this.interactiveLoginDismissed) {
throw new Error("Real-Debrid Web-Login abgebrochen");
}
const window = await this.ensureLoginWindow();
if (window.isMinimized()) {
window.restore();
}
@@ -596,11 +604,12 @@ export class RealDebridWebFallback {
throw new Error("Real-Debrid Web-Login abgebrochen");
}
const outcome = await this.generate(link, signal);
if (outcome.kind === "success") {
if (!window.isDestroyed()) {
window.close();
}
const outcome = await this.generate(link, signal);
if (outcome.kind === "success") {
if (!window.isDestroyed()) {
this.programmaticClosures.add(window);
window.close();
}
return outcome.value;
}