Add friends leaderboard, reverse button in add page
All checks were successful
Release / meta (push) Successful in 8s
Release / linux-build (push) Successful in 7m11s
Release / web-build (push) Successful in 5m3s
Release / android-build (push) Successful in 18m23s
Release / release-master (push) Successful in 22s
Release / release-dev (push) Successful in 25s
All checks were successful
Release / meta (push) Successful in 8s
Release / linux-build (push) Successful in 7m11s
Release / web-build (push) Successful in 5m3s
Release / android-build (push) Successful in 18m23s
Release / release-master (push) Successful in 22s
Release / release-dev (push) Successful in 25s
This commit is contained in:
@@ -108,6 +108,10 @@ class DataService extends ChangeNotifier {
|
||||
bool get isHomepageLoading => _isHomepageLoading;
|
||||
bool _isOnThisDayLoading = false;
|
||||
bool get isOnThisDayLoading => _isOnThisDayLoading;
|
||||
List<LeaderboardEntry> _friendsLeaderboard = [];
|
||||
List<LeaderboardEntry> get friendsLeaderboard => _friendsLeaderboard;
|
||||
bool _isFriendsLeaderboardLoading = false;
|
||||
bool get isFriendsLeaderboardLoading => _isFriendsLeaderboardLoading;
|
||||
|
||||
// Notifications
|
||||
List<UserNotification> _notifications = [];
|
||||
|
||||
@@ -25,4 +25,38 @@ extension DataServiceStats on DataService {
|
||||
_notifyAsync();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> fetchFriendsLeaderboard() async {
|
||||
if (_isFriendsLeaderboardLoading) return;
|
||||
_isFriendsLeaderboardLoading = true;
|
||||
_notifyAsync();
|
||||
try {
|
||||
final json = await api.get('/stats/leaderboard/friends');
|
||||
List<dynamic>? list;
|
||||
if (json is List) {
|
||||
list = json;
|
||||
} else if (json is Map) {
|
||||
for (final key in ['leaderboard', 'data', 'items', 'results']) {
|
||||
final value = json[key];
|
||||
if (value is List) {
|
||||
list = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_friendsLeaderboard = list
|
||||
?.whereType<Map>()
|
||||
.map((e) => LeaderboardEntry.fromJson(
|
||||
e.map((k, v) => MapEntry(k.toString(), v)),
|
||||
))
|
||||
.toList() ??
|
||||
const [];
|
||||
} catch (e) {
|
||||
debugPrint('Failed to fetch friends leaderboard: $e');
|
||||
_friendsLeaderboard = [];
|
||||
} finally {
|
||||
_isFriendsLeaderboardLoading = false;
|
||||
_notifyAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user