Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for delete account #424

Merged
merged 5 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/database/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:pilll/service/auth.dart';

final databaseProvider = Provider<DatabaseConnection>((ref) {
final stream = ref.watch(authStateStreamProvider);
final uid = stream.data?.value.uid;
final uid = stream.data?.value?.uid;
print("database uid is $uid");
if (uid == null) {
throw UnimplementedError("Must be called service/auth.dart callSignin");
Expand Down
5 changes: 5 additions & 0 deletions lib/domain/initial_setting/initial_setting_store.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ class InitialSettingStateStore extends StateNotifier<InitialSettingState> {
_subscribe() {
_authCanceller?.cancel();
_authCanceller = _authService.subscribe().listen((user) async {
print("watch sign state user: $user");
if (user == null) {
return;
}
print(
"watch sign state uid: ${user.uid}, isAnonymous: ${user.isAnonymous}");

final isAccountCooperationDidEnd = !user.isAnonymous;
if (isAccountCooperationDidEnd) {
final userService = UserService(DatabaseConnection(user.uid));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class DeleteUserButton extends StatelessWidget {
text: "退会する",
onPressed: () async {
await _delete(context);
Navigator.of(context).pop();
},
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SettingAccountCooperationListPageStore
_authCanceller?.cancel();
_authCanceller = _authService.subscribe().listen((user) {
print(
"watch sign state uid: ${user.uid}, isAnonymous: ${user.isAnonymous}");
"watch sign state uid: ${user?.uid}, isAnonymous: ${user?.isAnonymous}");
state = state.copyWith(user: user);
});
}
Expand Down
6 changes: 3 additions & 3 deletions lib/service/auth.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final authStateStreamProvider = StreamProvider(
);

class AuthService {
Stream<User> subscribe() {
Stream<User?> subscribe() {
return _subscribe();
}

Expand All @@ -37,13 +37,13 @@ class AuthInfo {
AuthInfo(this.uid);
}

Stream<User> _subscribe() {
Stream<User?> _subscribe() {
return StreamGroup.merge(
[
_cacheOrAuth().asStream(),
FirebaseAuth.instance.userChanges(),
],
).skipWhile((element) => element == null).cast();
);
}

Future<User?> callSignin() async {
Expand Down