winning games pushes feed
This commit is contained in:
@@ -90,6 +90,17 @@ class DbHelper {
|
||||
return items;
|
||||
}
|
||||
|
||||
static Future<void> pushFeedEntry(String text) async {
|
||||
await _supabase
|
||||
.from('feed')
|
||||
.insert({'text': text, 'timestamp': DateTime.now().toString()});
|
||||
}
|
||||
|
||||
static Future<void> pushGameWin(int currentPoints, int pointsWon) async {
|
||||
await _supabase.from('profiles').update(
|
||||
{'points': currentPoints + pointsWon}).eq('id', currentUser!.id);
|
||||
}
|
||||
|
||||
static Stream<List<Map<String, dynamic>>> get feedStream =>
|
||||
_supabase.from('feed').stream(primaryKey: ['timestamp']);
|
||||
|
||||
|
||||
@@ -21,6 +21,16 @@ class Profiles extends ChangeNotifier {
|
||||
return _profiles;
|
||||
}
|
||||
|
||||
Profile? get own {
|
||||
final list =
|
||||
profiles.where((element) => element.id == DbHelper.currentUser!.id);
|
||||
if (list.isNotEmpty) {
|
||||
return list.first;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
_updateProfile(List<Map<String, dynamic>> data) {
|
||||
final List<Profile> profiles = data.map((e) => Profile.fromMap(e)).toList();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user