Active User Flag
parent
c560f86db9
commit
d567956d90
|
@ -1,12 +1,17 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../components/text_bold.dart';
|
import '../components/text_bold.dart';
|
||||||
import '../services/auth/auth_gate.dart';
|
import '../services/auth/auth_gate.dart';
|
||||||
|
import '../services/auth/auth_service.dart';
|
||||||
|
import '../services/user_service.dart';
|
||||||
|
|
||||||
class RegistrationCompletePage extends StatelessWidget {
|
class RegistrationCompletePage extends StatelessWidget {
|
||||||
const RegistrationCompletePage({super.key});
|
const RegistrationCompletePage({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
// Set the user as active when the page is built
|
||||||
|
UserService.setUserActive(true, AuthService().getCurrentUser()!.uid);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
automaticallyImplyLeading: false, // remove back button
|
automaticallyImplyLeading: false, // remove back button
|
||||||
|
|
|
@ -98,10 +98,12 @@ class UserMatchingPageState extends State<UserMatchingPage> {
|
||||||
// add profiles accordingly
|
// add profiles accordingly
|
||||||
allUsers.add(userProfile);
|
allUsers.add(userProfile);
|
||||||
// Exclude (1) the current user's profile, (2) the already liked profiles
|
// Exclude (1) the current user's profile, (2) the already liked profiles
|
||||||
// and (3) users that were disliked less than 24 hours ago
|
// (3) users that were disliked less than 24 hours ago
|
||||||
|
// and (4) not active profile
|
||||||
if (userDoc.id != currentUserId &&
|
if (userDoc.id != currentUserId &&
|
||||||
!likedUserIds.contains(userDoc.id) &&
|
!likedUserIds.contains(userDoc.id) &&
|
||||||
!dislikedUserIds.contains(userDoc.id)) {
|
!dislikedUserIds.contains(userDoc.id) &&
|
||||||
|
(userProfile.active ?? false)) {
|
||||||
showProfiles.add(userProfile);
|
showProfiles.add(userProfile);
|
||||||
}
|
}
|
||||||
} // end for
|
} // end for
|
||||||
|
|
|
@ -365,4 +365,14 @@ class UserService {
|
||||||
return e.toString();
|
return e.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Update the active field of [userId] to given [value]
|
||||||
|
static Future<void> setUserActive(bool value, String userId) async {
|
||||||
|
await FirebaseFirestore.instance
|
||||||
|
.collection(Constants.dbCollectionUsers)
|
||||||
|
.doc(userId)
|
||||||
|
.update({
|
||||||
|
Constants.dbFieldUsersActive: value,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue