Fix: Bearbeiten eines Mega-Debrid-Accounts ändert nicht mehr heimlich die API/Web-Bevorzugung
Sind beide Mega-Debrid-Modi (API + Web) aktiv, entscheidet megaDebridPreferApi, welcher Modus zuerst versucht wird. Beim Speichern des Account-Dialogs hat applyAccountDialogToSettings diese Einstellung jedoch fest überschrieben: ein Bearbeiten der API-Zeile erzwang megaDebridPreferApi=true, ein Bearbeiten der Web-Zeile erzwang false. Wer also bewusst Web bevorzugt (preferApi=false) hatte und nur einen zweiten Account hinzufügen oder das Tageslimit ändern wollte und dafür die API-Zeile bearbeitete, dem wurde die Reihenfolge ungefragt auf "API zuerst" umgestellt — was die Provider-Auflösung für alle künftigen Mega-Links ändert. Fix: Die festen megaDebridPreferApi-Werte aus beiden Dialog-Zweigen entfernt. Der bestehende Wert wird über den ...settings-Spread durchgereicht. Erst-Anlage bleibt korrekt, weil der Default ohnehin true ist (constants). Bei nur EINEM aktiven Modus ist preferApi ohnehin irrelevant (die single-mode-Zweige kurzschließen davor). Test: bei beiden Modi aktiv + preferApi=false bleibt nach API-Edit false; bei preferApi=true bleibt nach Web-Edit true. Mit der alten Festverdrahtung kippt der Wert (rot bewiesen).
This commit is contained in:
@@ -109,7 +109,7 @@ interface MegaDialogAccount {
|
||||
password: string;
|
||||
}
|
||||
|
||||
interface AccountDialogState {
|
||||
export interface AccountDialogState {
|
||||
mode: "create" | "edit";
|
||||
kind: AccountKind | null;
|
||||
token: string;
|
||||
@@ -647,7 +647,7 @@ function createAccountDialogState(mode: "create" | "edit", kind: AccountKind | n
|
||||
}
|
||||
}
|
||||
|
||||
function applyAccountDialogToSettings(settings: AppSettings, dialog: AccountDialogState): AppSettings {
|
||||
export function applyAccountDialogToSettings(settings: AppSettings, dialog: AccountDialogState): AppSettings {
|
||||
if (!dialog.kind) {
|
||||
return settings;
|
||||
}
|
||||
@@ -682,7 +682,7 @@ function applyAccountDialogToSettings(settings: AppSettings, dialog: AccountDial
|
||||
const firstPassword = megaParsed.length > 0 ? megaParsed[0].password : "";
|
||||
const validIds = new Set(megaParsed.map((a) => a.id));
|
||||
const megaDebridDisabledAccountIds = (dialog.megaDisabledIds || []).filter((id) => validIds.has(id));
|
||||
return { ...settings, megaCredentials: megaSerialized, megaLogin: firstLogin, megaPassword: firstPassword, megaDebridApiEnabled: true, megaDebridPreferApi: true, megaDebridDisabledAccountIds, providerDailyLimitBytes: nextProviderDailyLimitBytes };
|
||||
return { ...settings, megaCredentials: megaSerialized, megaLogin: firstLogin, megaPassword: firstPassword, megaDebridApiEnabled: true, megaDebridDisabledAccountIds, providerDailyLimitBytes: nextProviderDailyLimitBytes };
|
||||
}
|
||||
case "megadebrid-web": {
|
||||
const megaSerialized = serializeMegaDebridAccounts(dialog.megaAccounts);
|
||||
@@ -691,7 +691,7 @@ function applyAccountDialogToSettings(settings: AppSettings, dialog: AccountDial
|
||||
const firstPassword = megaParsed.length > 0 ? megaParsed[0].password : "";
|
||||
const validIds = new Set(megaParsed.map((a) => a.id));
|
||||
const megaDebridDisabledAccountIds = (dialog.megaDisabledIds || []).filter((id) => validIds.has(id));
|
||||
return { ...settings, megaCredentials: megaSerialized, megaLogin: firstLogin, megaPassword: firstPassword, megaDebridWebEnabled: true, megaDebridPreferApi: false, megaDebridDisabledAccountIds, providerDailyLimitBytes: nextProviderDailyLimitBytes };
|
||||
return { ...settings, megaCredentials: megaSerialized, megaLogin: firstLogin, megaPassword: firstPassword, megaDebridWebEnabled: true, megaDebridDisabledAccountIds, providerDailyLimitBytes: nextProviderDailyLimitBytes };
|
||||
}
|
||||
case "bestdebrid-api":
|
||||
return { ...settings, bestToken: token, bestDebridUseWebLogin: false, providerDailyLimitBytes: nextProviderDailyLimitBytes };
|
||||
|
||||
Reference in New Issue
Block a user