fix(connection): keep selected app when switching platform

Switching the platform dropdown always reset the app to the new platform's
featured/first one, discarding the user's choice (e.g. picked Happ → switched
platform → snapped back to the first app). Now it keeps the same app by name if
it exists on the new platform, falling back to featured/first only otherwise.
This commit is contained in:
c0mrade
2026-06-03 16:22:41 +03:00
parent c91c9e0441
commit f8ac4895fa

View File

@@ -266,7 +266,12 @@ export default function InstallationGuide({
setActivePlatformKey(newPlatform); setActivePlatformKey(newPlatform);
const data = appConfig.platforms[newPlatform] as RemnawavePlatformData | undefined; const data = appConfig.platforms[newPlatform] as RemnawavePlatformData | undefined;
if (data?.apps?.length) { if (data?.apps?.length) {
const app = data.apps.find((a) => a.featured) || data.apps[0]; // Keep the user's current app (by name) if it also exists on the
// new platform; only fall back to featured/first otherwise.
const app =
data.apps.find((a) => a.name === selectedApp?.name) ||
data.apps.find((a) => a.featured) ||
data.apps[0];
if (app) setSelectedApp(app); if (app) setSelectedApp(app);
} }
}} }}