Skip to content

Commit

Permalink
Merge pull request #424 from bannzai/fix/function/user_delete
Browse files Browse the repository at this point in the history
Bugfix for delete account
  • Loading branch information
bannzai committed Nov 13, 2021
2 parents 3f98771 + f917d81 commit 7758d40
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
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

0 comments on commit 7758d40

Please sign in to comment.