winning games pushes feed

This commit is contained in:
SomnusVeritas
2023-10-21 01:30:04 +02:00
parent 03c4ca34d6
commit c951458d4c
3 changed files with 67 additions and 13 deletions

View File

@@ -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']);