Ensure new profile starts empty

This commit is contained in:
Janez T
2026-03-16 14:04:07 +01:00
parent 450b8382e8
commit 0e3acfa4ca
3 changed files with 342 additions and 10 deletions

View File

@@ -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);
}
}