fix: Profile coordinator null safety and data loss

This commit is contained in:
Janez T
2026-03-16 22:23:46 +01:00
parent c884f81ca5
commit a76ee4f8f6

View File

@@ -212,7 +212,8 @@ class ProfileWorkspaceCoordinator {
if (profileId == ConfigProfile.defaultProfileId) {
return snapshotCurrentProfile(id: profileId, name: 'Default');
}
return profileManager.getProfile(profileId)!;
return profileManager.getProfile(profileId) ??
await snapshotCurrentProfile(id: profileId, name: 'Unknown');
}
Future<void> exportProfile(ConfigProfile profile) async {
@@ -300,7 +301,10 @@ class ProfileWorkspaceCoordinator {
return;
}
final current = profileManager.getProfile(profileManager.activeProfileId);
if (current == null) return;
if (current == null) {
await _persistCurrentState();
return;
}
final snapshot = await snapshotCurrentProfile(
id: current.id,
name: current.name,