|
@@ -1,3 +1,5 @@
|
|
|
+// import 'dart:ffi';
|
|
|
+
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:http/http.dart' as http;
|
|
|
import 'dart:convert';
|
|
@@ -146,24 +148,66 @@ class _EmailPageState extends State<EmailPage> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Future<void> getEmailJson(String threadId) async {
|
|
|
+ // // List< jsonTypeShit = "";
|
|
|
+ // try {
|
|
|
+ // var url = Uri.http(
|
|
|
+ // '127.0.0.1:3001', 'get_thread_messages', {'id': threadId.toString()});
|
|
|
+ // // print(url);
|
|
|
+ // var response = await http.get(url);
|
|
|
+ // // print(response.body);
|
|
|
+ // if (response.statusCode == 200) {
|
|
|
+ // List<dynamic> messagesJson = jsonDecode(response.body);
|
|
|
+ // print(messagesJson);
|
|
|
+ // print("1");
|
|
|
+ // List<SerializableMessage> messages =
|
|
|
+ // messagesJson.map((mj) => SerializableMessage.fromJson(mj)).toList();
|
|
|
+ // // allEmails.addAll(messages);
|
|
|
+
|
|
|
+ // print(messages);
|
|
|
+ // // jsonTypeShit = messages;
|
|
|
+ // } else {
|
|
|
+ // throw Exception(
|
|
|
+ // 'Failed to fetch thread messages for thread ID: $threadId');
|
|
|
+ // }
|
|
|
+ // } catch (e) {
|
|
|
+ // print('Error fetching thread messages: $e');
|
|
|
+ // }
|
|
|
+ // // return(messages)
|
|
|
+ // }
|
|
|
+
|
|
|
Future<String> _getEmailContent(String id) async {
|
|
|
String content = r"""
|
|
|
|
|
|
""";
|
|
|
+ String restcontent = "";
|
|
|
try {
|
|
|
var url = Uri.http('127.0.0.1:3001', 'email', {'id': id});
|
|
|
- print(url);
|
|
|
+ // print(url);
|
|
|
var response = await http.get(url);
|
|
|
- print(response.body);
|
|
|
+ // print(response.body);
|
|
|
if (response.statusCode == 200) {
|
|
|
print('ok');
|
|
|
content = response.body;
|
|
|
+ try {
|
|
|
+ var restUrl =
|
|
|
+ Uri.http('127.0.0.1:3001', 'get_thread_messages', {'id': id});
|
|
|
+ print(restUrl);
|
|
|
+ var restresponse = await http.get(restUrl);
|
|
|
+ print(restresponse.statusCode);
|
|
|
+ if (restresponse.statusCode == 200) {
|
|
|
+ print("ok squared");
|
|
|
+ restcontent = restresponse.body;
|
|
|
+ }
|
|
|
+ } catch (i) {
|
|
|
+ print('jsoncontent caught error: $i');
|
|
|
+ }
|
|
|
}
|
|
|
} catch (e) {
|
|
|
print('_getEmailContent caught error: $e');
|
|
|
}
|
|
|
// print(content);
|
|
|
-
|
|
|
+ print(restcontent);
|
|
|
return content;
|
|
|
}
|
|
|
|
|
@@ -232,7 +276,7 @@ class _EmailPageState extends State<EmailPage> {
|
|
|
}
|
|
|
|
|
|
class EmailListScreen extends StatelessWidget {
|
|
|
- List emails;
|
|
|
+ final List emails;
|
|
|
final Future<String> Function(String) getEmailContent;
|
|
|
|
|
|
EmailListScreen({required this.emails, required this.getEmailContent});
|