Skip to content

Commit

Permalink
Fix review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MDikkii committed Jan 6, 2025
1 parent 99ebeeb commit eb83043
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
19 changes: 9 additions & 10 deletions recipients_app/lib/core/cubits/auth/auth_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ class AuthCubit extends Cubit<AuthState> {
if (user != null) {
try {
final recipient = await userRepository.fetchRecipient(user);
Organization? organization;

if (recipient?.organizationRef != null) {
organization = await organizationRepository.fetchOrganization(recipient!.organizationRef!);
}
final Organization? organization = await _fetchOrganization(recipient);

emit(
AuthState(
Expand Down Expand Up @@ -62,11 +58,7 @@ class AuthCubit extends Cubit<AuthState> {

if (user != null) {
final recipient = await userRepository.fetchRecipient(user);
Organization? organization;

if (recipient?.organizationRef != null) {
organization = await organizationRepository.fetchOrganization(recipient!.organizationRef!);
}
final Organization? organization = await _fetchOrganization(recipient);

emit(
AuthState(
Expand Down Expand Up @@ -109,4 +101,11 @@ class AuthCubit extends Cubit<AuthState> {
await userRepository.signOut();
emit(const AuthState());
}

Future<Organization?> _fetchOrganization(Recipient? recipient) async {
if (recipient?.organizationRef != null) {
return await organizationRepository.fetchOrganization(recipient!.organizationRef!);
}
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,66 +1,58 @@
import "package:cloud_firestore/cloud_firestore.dart";

// We are using DocumentReference in repository / data source. That's why we need to get
// no-op implementation for it for demo data source.

// ignore: subtype_of_sealed_class
class NoOpDocumentReference implements DocumentReference<Map<String, dynamic>> {
const NoOpDocumentReference();

@override
CollectionReference<Map<String, dynamic>> collection(String collectionPath) {
// TODO: implement collection
throw UnimplementedError();
}

@override
Future<void> delete() {
// TODO: implement delete
throw UnimplementedError();
}

@override
// TODO: implement firestore
FirebaseFirestore get firestore => throw UnimplementedError();

@override
Future<DocumentSnapshot<Map<String, dynamic>>> get([GetOptions? options]) {
// TODO: implement get
throw UnimplementedError();
}

@override
// TODO: implement id
String get id => throw UnimplementedError();

@override
// TODO: implement parent
CollectionReference<Map<String, dynamic>> get parent => throw UnimplementedError();

@override
// TODO: implement path
String get path => throw UnimplementedError();

@override
Future<void> set(Map<String, dynamic> data, [SetOptions? options]) {
// TODO: implement set
throw UnimplementedError();
}

@override
Stream<DocumentSnapshot<Map<String, dynamic>>> snapshots(
{bool includeMetadataChanges = false, ListenSource source = ListenSource.defaultSource,}) {
// TODO: implement snapshots
throw UnimplementedError();
}

@override
Future<void> update(Map<Object, Object?> data) {
// TODO: implement update
throw UnimplementedError();
}

@override
DocumentReference<R> withConverter<R>(
{required FromFirestore<R> fromFirestore, required ToFirestore<R> toFirestore,}) {
// TODO: implement withConverter
throw UnimplementedError();
}
}

0 comments on commit eb83043

Please sign in to comment.