Basic publisher page

This commit is contained in:
2024-12-01 22:30:32 +08:00
parent 32739821ba
commit 23c5a1a23e
10 changed files with 347 additions and 21 deletions

View File

@ -63,10 +63,15 @@ class SnPostContentProvider {
return out;
}
Future<(List<SnPost>, int)> listPosts({int take = 10, int offset = 0}) async {
Future<(List<SnPost>, int)> listPosts({
int take = 10,
int offset = 0,
String? author,
}) async {
final resp = await _sn.client.get('/cgi/co/posts', queryParameters: {
'take': take,
'offset': offset,
if (author != null) 'author': author,
});
final List<SnPost> out = await _preloadRelatedDataInBatch(
List.from(resp.data['data']?.map((e) => SnPost.fromJson(e)) ?? []),

View File

@ -89,12 +89,6 @@ class WebSocketProvider extends ChangeNotifier {
final packet = WebSocketPackage.fromJson(jsonDecode(event));
log('Websocket incoming message: ${packet.method} ${packet.message}');
stream.sink.add(packet);
// TODO handle notification
// if (packet.method == 'notifications.new') {
// final NotificationProvider nty = Get.find();
// nty.notifications.add(Notification.fromJson(packet.payload!));
// nty.notificationUnread.value++;
// }
},
onDone: () {
isConnected = false;