Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: remove anon user when sign up with a new user (#4253)

Nathan.fooo8ccd1ec72c6e
diff --git a/frontend/appflowy_flutter/integration_test/cloud/anon_user_continue_test.dart b/frontend/appflowy_flutter/integration_test/cloud/anon_user_continue_test.dart
index 45f7f2e359..709d095661 100644
--- a/frontend/appflowy_flutter/integration_test/cloud/anon_user_continue_test.dart
+++ b/frontend/appflowy_flutter/integration_test/cloud/anon_user_continue_test.dart
@@ -56,14 +56,14 @@ void main() {
// tap the continue as anonymous button
await tester
- .tapButton(find.text(LocaleKeys.signIn_continueAnonymousUser.tr()));
+ .tapButton(find.text(LocaleKeys.signIn_loginStartWithAnonymous.tr()));
await tester.expectToSeeHomePage();
- // assert the name of the anon user is local_user
+ // New anon user name
await tester.openSettings();
await tester.openSettingsPage(SettingsPage.user);
final userNameInput = tester.widget(userNameFinder) as UserNameInput;
- expect(userNameInput.name, 'local_user');
+ expect(userNameInput.name, 'Me');
});
});
}
diff --git a/frontend/rust-lib/flowy-user/src/manager.rs b/frontend/rust-lib/flowy-user/src/manager.rs
index ea3bc3a0fb..4c9d0c65a8 100644
--- a/frontend/rust-lib/flowy-user/src/manager.rs
+++ b/frontend/rust-lib/flowy-user/src/manager.rs
@@ -415,6 +415,7 @@ impl UserManager {
self
.migrate_anon_user_data_to_cloud(&old_user, &new_user, authenticator)
.await?;
+ self.remove_anon_user();
let _ = self.database.close(old_user.session.user_id);
}
}
diff --git a/frontend/rust-lib/flowy-user/src/services/historical_user.rs b/frontend/rust-lib/flowy-user/src/services/historical_user.rs
index 22a2dd817b..5ca1072b36 100644
--- a/frontend/rust-lib/flowy-user/src/services/historical_user.rs
+++ b/frontend/rust-lib/flowy-user/src/services/historical_user.rs
@@ -40,6 +40,10 @@ impl UserManager {
let _ = self.store_preferences.set_object(ANON_USER, session);
}
+ pub fn remove_anon_user(&self) {
+ self.store_preferences.remove(ANON_USER);
+ }
+
pub async fn get_anon_user(&self) -> FlowyResult<UserProfilePB> {
let anon_session = self
.store_preferences