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

* chore: remove anon user when sign up with a new user

* chore: clippy
This commit is contained in:
Nathan.fooo 2023-12-30 09:36:22 +08:00 committed by GitHub
parent 7ba3020ab3
commit 8ccd1ec72c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View File

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

View File

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

View File

@ -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