fix(accounts): refresh status before enabling accounts

Validate Real-Debrid, Mega-Debrid, and Debrid-Link accounts silently before exposing a newly enabled account to active downloads. Keep the row toggle optimistic, skip network checks while disabling, persist direct account-check results, and avoid the browser-login race for an already authenticated Real-Debrid web session.
This commit is contained in:
Sucukdeluxe
2026-08-15 21:41:38 +02:00
parent d720c5912e
commit 82303dc94a
5 changed files with 83 additions and 12 deletions
+10 -4
View File
@@ -598,15 +598,21 @@ export class AppController {
? parseMegaDebridAccounts(`${input.identity.trim()}:${input.secret}`)[0]
: getMegaDebridAccountsForMode(this.settings, mode).find((entry) => entry.id === input.accountId);
if (!account) throw new Error("Account-Payload ist ungültig");
const status = await checkMegaDebridAccount(account);
return sanitizeDebridAccountStatus(status, redactions);
const status = sanitizeDebridAccountStatus(await checkMegaDebridAccount(account), redactions);
if (!input.secret && getMegaDebridAccountsForMode(this.settings, mode).some((entry) => entry.id === status.accountId)) {
this.manager.applyDebridAccountStatuses([status]);
}
return status;
}
const key = input.secret?.trim()
? parseDebridLinkApiKeys(input.secret)[0]
: parseDebridLinkApiKeys(this.settings.debridLinkApiKeys).find((entry) => entry.id === input.accountId);
if (!key) throw new Error("Account-Payload ist ungültig");
const status = await checkDebridLinkKey(key);
return sanitizeDebridAccountStatus(status, redactions);
const status = sanitizeDebridAccountStatus(await checkDebridLinkKey(key), redactions);
if (!input.secret && parseDebridLinkApiKeys(this.settings.debridLinkApiKeys).some((entry) => entry.id === status.accountId)) {
this.manager.applyDebridAccountStatuses([status]);
}
return status;
}
public resetProviderDailyUsage(provider: DebridProvider): AppSettings {