👽 Support new activity API

This commit is contained in:
2025-06-09 01:06:52 +08:00
parent 7740cf7830
commit 1f46f89056
8 changed files with 50 additions and 125 deletions

View File

@ -7,7 +7,7 @@ part of 'room_detail.dart';
// **************************************************************************
String _$chatMemberListNotifierHash() =>
r'f14dbb3c6ccfef26a49d8bf5dd53b05f7c63eb6c';
r'f2191a631ba00ae3de39ccac10e4cdd065ffee17';
/// Copied from Dart SDK
class _SystemHash {

View File

@ -168,12 +168,6 @@ class _ActivityListView extends HookConsumerWidget {
);
}
break;
case 'accounts.check-in':
itemWidget = CheckInActivityWidget(item: item);
break;
case 'accounts.status':
itemWidget = StatusActivityWidget(item: item);
break;
default:
itemWidget = const Placeholder();
}
@ -196,12 +190,14 @@ class ActivityListNotifier extends _$ActivityListNotifier
@override
Future<CursorPagingData<SnActivity>> fetch({required String? cursor}) async {
final client = ref.read(apiClientProvider);
final offset = cursor == null ? 0 : int.parse(cursor);
final take = 20;
final response = await client.get(
'/activities',
queryParameters: {'offset': offset, 'take': take},
queryParameters: {
if (cursor != null) 'reading_cursor': cursor,
'take': take,
},
);
final List<SnActivity> items =
@ -209,9 +205,9 @@ class ActivityListNotifier extends _$ActivityListNotifier
.map((e) => SnActivity.fromJson(e as Map<String, dynamic>))
.toList();
final total = int.tryParse(response.headers['x-total']?.first ?? '') ?? 0;
final hasMore = offset + items.length < total;
final nextCursor = hasMore ? (offset + items.length).toString() : null;
final hasMore = (items.firstOrNull?.type ?? 'empty') != 'empty';
final nextCursor =
items.map((x) => x.createdAt).lastOrNull?.toIso8601String().toString();
return CursorPagingData(
items: items,

View File

@ -7,7 +7,7 @@ part of 'explore.dart';
// **************************************************************************
String _$activityListNotifierHash() =>
r'8a67d302e828408c7c4cf724d84c2c5958f2dc7e';
r'1baf0bb961bc02bfc8a5b5f515981072c6ce1750';
/// See also [ActivityListNotifier].
@ProviderFor(ActivityListNotifier)