fix(accounts): unlock parent provider when enabling rows

Make individual Debrid-Link and Mega-Debrid switches express an explicit enabled target. Enabling a row now clears both its own disabled identifier and the effective provider lock; Mega-Debrid also re-enables the selected API or web mode.

Keep row-level disabling scoped to the selected account, align the legacy key view with the effective provider state, and cover the provider-plus-account lock combination with a regression test.
This commit is contained in:
Sucukdeluxe
2026-08-15 01:19:29 +02:00
parent 0119534e07
commit 479c2b600a
4 changed files with 80 additions and 22 deletions
+26
View File
@@ -7,6 +7,7 @@ import { createRendererSettings, createRendererState } from "../src/main/rendere
import { buildAccountAddFields, createAccountDialogState } from "../src/renderer/App";
import { buildAccountReplaceCommand, createAccountEditState, type AccountEditTarget } from "../src/renderer/account-edit";
import {
buildScopedAccountEnabledState,
buildBulkAccountEnabledState,
buildConfiguredProviderOrder,
resolveAccountStatusState,
@@ -958,6 +959,31 @@ describe("account workspace", () => {
});
describe("settings App integration", () => {
it("enables an account by clearing both its row-level and provider-level locks", () => {
expect(buildScopedAccountEnabledState(
["debridlink", "linksnappy"],
["debridlink"],
["key-disabled", "key-other"],
"key-disabled",
true
)).toEqual({
disabledProviders: ["linksnappy"],
disabledAccountIds: ["key-other"]
});
expect(buildScopedAccountEnabledState([], ["debridlink"], [], "key-active", false)).toEqual({
disabledProviders: [],
disabledAccountIds: ["key-active"]
});
const debridLinkBlock = sourceBlock(appSource, "const onToggleDebridLinkApiKeyEnabled", "const onAccountRowQuickAction");
const megaBlock = sourceBlock(appSource, "const onToggleMegaAccountEnabled", "const onRemoveDebridLinkKey");
expect(debridLinkBlock).toContain("buildScopedAccountEnabledState");
expect(megaBlock).toContain("buildScopedAccountEnabledState");
expect(megaBlock).toContain('megaDebridApiEnabled: mode === "api" && enabled ? true');
expect(megaBlock).toContain('megaDebridWebEnabled: mode === "web" && enabled ? true');
});
it("shows a failed all-account check even when the account is disabled", () => {
expect(resolveAccountStatusState(true, { valid: false, isPremium: false })).toBe("invalid");
expect(resolveAccountStatusState(true, { valid: true, isPremium: true })).toBe("disabled");