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
+18
View File
@@ -89,6 +89,24 @@ export async function runOptimisticAccountUpdate<T>(
}
}
export function buildScopedAccountEnabledState(
currentDisabledProviders: DebridProvider[],
providerIds: DebridProvider[],
currentDisabledAccountIds: string[],
accountId: string,
enabled: boolean
): { disabledProviders: DebridProvider[]; disabledAccountIds: string[] } {
const providers = new Set(providerIds);
return {
disabledProviders: enabled
? currentDisabledProviders.filter((provider) => !providers.has(provider))
: [...currentDisabledProviders],
disabledAccountIds: enabled
? currentDisabledAccountIds.filter((id) => id !== accountId)
: [...new Set([...currentDisabledAccountIds, accountId])]
};
}
export function buildBulkAccountEnabledState(
currentDisabledProviders: DebridProvider[],
configuredProviders: DebridProvider[],