mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
Ensure new profile starts empty
This commit is contained in:
@@ -92,14 +92,6 @@ class ProfilesScreen extends StatelessWidget {
|
||||
},
|
||||
child: const Text('Open'),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () async {
|
||||
await context
|
||||
.read<ProfileWorkspaceCoordinator>()
|
||||
.applyProfile(profile.id);
|
||||
},
|
||||
child: const Text('Apply'),
|
||||
),
|
||||
OutlinedButton(
|
||||
onPressed: () async {
|
||||
final resolved =
|
||||
|
||||
@@ -134,8 +134,7 @@ class ProfileWorkspaceCoordinator {
|
||||
name: name,
|
||||
notes: notes,
|
||||
);
|
||||
await messagesProvider.cloneCurrentStorageTo(profileId);
|
||||
await contactsProvider.cloneCurrentStorageTo(profileId);
|
||||
await _initializeEmptyStorageNamespace(profileId);
|
||||
await profileManager.upsertProfile(profile);
|
||||
return profile;
|
||||
}
|
||||
@@ -180,6 +179,7 @@ class ProfileWorkspaceCoordinator {
|
||||
|
||||
Future<void> openProfile(String profileId) async {
|
||||
await _saveActiveCustomProfileSnapshot();
|
||||
await connectionProvider.disconnect();
|
||||
await profileManager.setActiveProfileId(profileId);
|
||||
await _switchRuntimeScope(profileId);
|
||||
|
||||
@@ -360,4 +360,11 @@ class ProfileWorkspaceCoordinator {
|
||||
namespace: targetNamespace,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _initializeEmptyStorageNamespace(String namespace) async {
|
||||
await _messageStorageService.clearMessages(namespace: namespace);
|
||||
await _contactStorageService.clearContacts(namespace: namespace);
|
||||
await _contactStorageService.clearContactGroups(namespace: namespace);
|
||||
await _contactStorageService.clearPendingAdverts(namespace: namespace);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user