2022-04-15 04:03:42 +00:00
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:wind/message_item_view.dart';
|
|
|
|
import 'package:wind/nntp_client.dart';
|
|
|
|
|
|
|
|
class ThreadModel extends ChangeNotifier {
|
|
|
|
NNTPClient? client;
|
|
|
|
|
2022-04-17 23:35:03 +00:00
|
|
|
var commentTextController = TextEditingController(text: "");
|
2022-04-17 23:26:57 +00:00
|
|
|
|
|
|
|
Future<MessageItem> getPost(int number) async {
|
|
|
|
var msg = await client!.getPost(number);
|
|
|
|
return MessageItem(
|
|
|
|
msg.getHeaderValue("Message-Id")!,
|
|
|
|
number,
|
|
|
|
msg.getHeaderValue("Subject")!,
|
|
|
|
msg.getHeaderValue("From")!,
|
|
|
|
msg.getHeaderValue("Date")!,
|
|
|
|
msg.decodeTextPlainPart()!);
|
|
|
|
}
|
|
|
|
|
2022-04-15 04:03:42 +00:00
|
|
|
Future<List<MessageItem>> getThread(int threadNumber) async {
|
|
|
|
if (client!.currentGroup == "") return [];
|
|
|
|
|
|
|
|
List<MessageItem> items = [];
|
|
|
|
|
|
|
|
var thread = await client!.getThread(threadNumber);
|
|
|
|
|
|
|
|
thread.forEach((pair) {
|
|
|
|
var messageNum = pair.item1;
|
|
|
|
var message = pair.item2;
|
|
|
|
items.add(MessageItem(
|
|
|
|
message.getHeaderValue("Message-Id")!,
|
|
|
|
messageNum,
|
|
|
|
null,
|
|
|
|
message.getHeaderValue("From")!,
|
|
|
|
message.getHeaderValue("Date")!,
|
|
|
|
message.decodeTextPlainPart()!));
|
|
|
|
});
|
|
|
|
|
|
|
|
return items;
|
|
|
|
}
|
|
|
|
}
|