purged unnecessay comments out, and dead code
This commit is contained in:
parent
254972d2af
commit
f867312af3
@ -28,56 +28,7 @@ class MailAddress {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// //data structure
|
|
||||||
// class SerializableMessage {
|
|
||||||
// final String name;
|
|
||||||
// final String from;
|
|
||||||
// final List<MailAddress> to;
|
|
||||||
// final List<MailAddress> cc;
|
|
||||||
// final String hash;
|
|
||||||
|
|
||||||
// final String subject;
|
|
||||||
// final String date;
|
|
||||||
// final int uid;
|
|
||||||
// final String list;
|
|
||||||
// final String id;
|
|
||||||
// final String in_reply_to;
|
|
||||||
|
|
||||||
// SerializableMessage({
|
|
||||||
// required this.name,
|
|
||||||
// required this.from,
|
|
||||||
// required this.to,
|
|
||||||
// required this.cc,
|
|
||||||
// required this.hash,
|
|
||||||
// required this.subject,
|
|
||||||
// required this.date,
|
|
||||||
// required this.uid,
|
|
||||||
// required this.list,
|
|
||||||
// required this.id,
|
|
||||||
// required this.in_reply_to,
|
|
||||||
// });
|
|
||||||
|
|
||||||
// factory SerializableMessage.fromJson(Map<String, dynamic> json) {
|
|
||||||
// var toList = json['to'] as List;
|
|
||||||
// var ccList = json['cc'] as List;
|
|
||||||
|
|
||||||
// return SerializableMessage(
|
|
||||||
// name: json['name'],
|
|
||||||
// from: json['from'],
|
|
||||||
// // to: json['name', 'address']
|
|
||||||
// to: toList.map((i) => MailAddress.fromJson(i)).toList(),
|
|
||||||
// cc: ccList.map((i) => MailAddress.fromJson(i)).toList(),
|
|
||||||
// // path: json['path'],
|
|
||||||
// hash: json['hash'],
|
|
||||||
// subject: json['subject'],
|
|
||||||
// date: json['date'],
|
|
||||||
// uid: json['uid'],
|
|
||||||
// list: json['list'],
|
|
||||||
// id: json['id'],
|
|
||||||
// in_reply_to: json['in_reply_to'],
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
class EmailPage extends StatefulWidget {
|
class EmailPage extends StatefulWidget {
|
||||||
const EmailPage({super.key});
|
const EmailPage({super.key});
|
||||||
@ -91,7 +42,6 @@ class _EmailPageState extends State<EmailPage> {
|
|||||||
List emails = [];
|
List emails = [];
|
||||||
|
|
||||||
void _displayEmailsFromFolder(String folder) async {
|
void _displayEmailsFromFolder(String folder) async {
|
||||||
// Map<String, List<SerializableMessage>> messagesMap = {};
|
|
||||||
List<GetThreadResponse> allEmails = []; //all the emails
|
List<GetThreadResponse> allEmails = []; //all the emails
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -106,11 +56,8 @@ class _EmailPageState extends State<EmailPage> {
|
|||||||
if (item.length > 1 && item[0] is String && item[1] is List) {
|
if (item.length > 1 && item[0] is String && item[1] is List) {
|
||||||
List<int> threadIDs = List<int>.from(item[1]);
|
List<int> threadIDs = List<int>.from(item[1]);
|
||||||
for (var threadId in threadIDs) {
|
for (var threadId in threadIDs) {
|
||||||
// print(threadId);
|
|
||||||
// await fetchThreadMessages(threadId, allEmails);
|
|
||||||
await fetchThreads(threadId, allEmails);
|
await fetchThreads(threadId, allEmails);
|
||||||
}
|
}
|
||||||
//TODO: get exact thread with new api endpoint from chosen thread?
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -124,39 +71,22 @@ class _EmailPageState extends State<EmailPage> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
emails = allEmails;
|
emails = allEmails;
|
||||||
});
|
});
|
||||||
// print(emails[0]);
|
|
||||||
// Print allEmails to debug its structure
|
|
||||||
// print("allEmails: ${allEmails[0].messages}");
|
|
||||||
|
|
||||||
// Convert allEmails to a list
|
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
Future<void> fetchThreads(
|
Future<void> fetchThreads(
|
||||||
//complete
|
|
||||||
int threadId,
|
int threadId,
|
||||||
List<GetThreadResponse> allEmails) async {
|
List<GetThreadResponse> allEmails) async {
|
||||||
try {
|
try {
|
||||||
var url =
|
var url =
|
||||||
Uri.http('127.0.0.1:3001', 'get_thread', {'id': threadId.toString()});
|
Uri.http('127.0.0.1:3001', 'get_thread', {'id': threadId.toString()});
|
||||||
var response = await http.get(url);
|
var response = await http.get(url);
|
||||||
// print(response.body);
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
Map<String, dynamic> messagesJson = jsonDecode(response.body);
|
Map<String, dynamic> messagesJson = jsonDecode(response.body);
|
||||||
// print(messagesJson);
|
GetThreadResponse threadResponse =
|
||||||
// List<String> messagesofThread = messagesJson['messages'];
|
|
||||||
// messagesJson.map((mj) => GetThreadResponse.fromJson(mj)).toList();
|
|
||||||
// List<GetThreadResponse> messages = messagesJson.values.map((mj) {
|
|
||||||
// return GetThreadResponse.fromJson(mj as Map<String, dynamic>);
|
|
||||||
// }).toList();
|
|
||||||
// List<GetThreadResponse> thread =
|
|
||||||
// messagesJson.map((mj) => GetThreadResponse.fromJson(mj)).toList();
|
|
||||||
GetThreadResponse threadResponse =
|
|
||||||
GetThreadResponse.fromJson(messagesJson);
|
GetThreadResponse.fromJson(messagesJson);
|
||||||
|
|
||||||
allEmails.add(
|
allEmails.add(threadResponse);
|
||||||
threadResponse); //adds all the messages of the thread into all emails
|
|
||||||
//perhaps should change
|
|
||||||
} else {
|
} else {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
'Failed to fetch thread messages for thread ID: $threadId');
|
'Failed to fetch thread messages for thread ID: $threadId');
|
||||||
@ -166,28 +96,6 @@ class _EmailPageState extends State<EmailPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Future<void> fetchThreadMessages(
|
|
||||||
// int threadId, List<SerializableMessage> allEmails) async {
|
|
||||||
// try {
|
|
||||||
// var url = Uri.http(
|
|
||||||
// '127.0.0.1:3001', 'get_thread_messages', {'id': threadId.toString()});
|
|
||||||
|
|
||||||
// var response = await http.get(url);
|
|
||||||
|
|
||||||
// if (response.statusCode == 200) {
|
|
||||||
// List<dynamic> messagesJson = jsonDecode(response.body);
|
|
||||||
// List<SerializableMessage> messages =
|
|
||||||
// messagesJson.map((mj) => SerializableMessage.fromJson(mj)).toList();
|
|
||||||
// allEmails.addAll(messages);
|
|
||||||
// } else {
|
|
||||||
// throw Exception(
|
|
||||||
// 'Failed to fetch thread messages for thread ID: $threadId');
|
|
||||||
// }
|
|
||||||
// } catch (e) {
|
|
||||||
// print('Error fetching thread messages: $e');
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
Future<String> _getEmailContent(List<String> IDs) async {
|
Future<String> _getEmailContent(List<String> IDs) async {
|
||||||
String content = r"""
|
String content = r"""
|
||||||
""";
|
""";
|
||||||
@ -205,7 +113,6 @@ class _EmailPageState extends State<EmailPage> {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('_getEmailContent caught error: $e');
|
print('_getEmailContent caught error: $e');
|
||||||
}
|
}
|
||||||
print(content);
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,18 +219,12 @@ class EmailListScreen extends StatelessWidget {
|
|||||||
onTap: () async {
|
onTap: () async {
|
||||||
String emailContent =
|
String emailContent =
|
||||||
await getEmailContent(emails[index].messages);
|
await getEmailContent(emails[index].messages);
|
||||||
String messages = emails[index].messages.toString();
|
|
||||||
String fromName = emails[index].from_name.toString();
|
String fromName = emails[index].from_name.toString();
|
||||||
String fromAddress = emails[index].from_address.toString();
|
String fromAddress = emails[index].from_address.toString();
|
||||||
String to = emails[index].to.toString();
|
String to = emails[index].to.toString();
|
||||||
// String cc = emails[index].cc.toString();
|
|
||||||
// String hash = emails[index].hash.toString();
|
|
||||||
String subject = emails[index].subject.toString();
|
String subject = emails[index].subject.toString();
|
||||||
String date = emails[index].date.toString();
|
String date = emails[index].date.toString();
|
||||||
// String uid = emails[index].uid.toString();
|
|
||||||
// String list = emails[index].list.toString();
|
|
||||||
String id = emails[index].id.toString();
|
String id = emails[index].id.toString();
|
||||||
// String in_reply_to = emails[index].in_reply_to.toString();
|
|
||||||
|
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
@ -333,16 +234,10 @@ class EmailListScreen extends StatelessWidget {
|
|||||||
from: fromAddress,
|
from: fromAddress,
|
||||||
name: fromName,
|
name: fromName,
|
||||||
to: to,
|
to: to,
|
||||||
// cc: cc,
|
|
||||||
// hash: hash,
|
|
||||||
subject: subject,
|
subject: subject,
|
||||||
date: date,
|
date: date,
|
||||||
// uid: uid,
|
|
||||||
// list: list,
|
|
||||||
id: id,
|
id: id,
|
||||||
// in_reply_to: in_reply_to,
|
|
||||||
)
|
)
|
||||||
//nada hpta
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -357,39 +252,22 @@ class EmailListScreen extends StatelessWidget {
|
|||||||
|
|
||||||
class EmailView extends StatefulWidget {
|
class EmailView extends StatefulWidget {
|
||||||
final String emailContent;
|
final String emailContent;
|
||||||
// final String jsonEmail;
|
|
||||||
final String from;
|
final String from;
|
||||||
final String name;
|
final String name;
|
||||||
|
|
||||||
final String to;
|
final String to;
|
||||||
|
|
||||||
// final String to;
|
|
||||||
// final String cc;
|
|
||||||
// final String hash;
|
|
||||||
final String subject;
|
final String subject;
|
||||||
final String date;
|
final String date;
|
||||||
// final String uid;
|
|
||||||
// final String list;
|
|
||||||
final String id;
|
final String id;
|
||||||
// final String in_reply_to;
|
|
||||||
|
|
||||||
const EmailView({
|
const EmailView({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.emailContent,
|
required this.emailContent,
|
||||||
// required this.jsonEmail,
|
|
||||||
required this.from,
|
required this.from,
|
||||||
required this.name,
|
required this.name,
|
||||||
required this.to,
|
required this.to,
|
||||||
|
|
||||||
// required this.to,
|
|
||||||
// required this.cc,
|
|
||||||
// required this.hash,
|
|
||||||
required this.subject,
|
required this.subject,
|
||||||
required this.date,
|
required this.date,
|
||||||
// required this.uid,
|
|
||||||
// required this.list,
|
|
||||||
required this.id,
|
required this.id,
|
||||||
// required this.in_reply_to
|
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
@override
|
@override
|
||||||
_EmailViewState createState() => _EmailViewState();
|
_EmailViewState createState() => _EmailViewState();
|
||||||
@ -426,7 +304,7 @@ class _EmailViewState extends State<EmailView> {
|
|||||||
AugmentClasses.handleJump(spanId);
|
AugmentClasses.handleJump(spanId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// void _invisibility(String )
|
// TODO: void _invisibility(String )
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -45,3 +45,55 @@ class GetThreadResponse {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// //old data structure
|
||||||
|
// class SerializableMessage {
|
||||||
|
// final String name;
|
||||||
|
// final String from;
|
||||||
|
// final List<MailAddress> to;
|
||||||
|
// final List<MailAddress> cc;
|
||||||
|
// final String hash;
|
||||||
|
|
||||||
|
// final String subject;
|
||||||
|
// final String date;
|
||||||
|
// final int uid;
|
||||||
|
// final String list;
|
||||||
|
// final String id;
|
||||||
|
// final String in_reply_to;
|
||||||
|
|
||||||
|
// SerializableMessage({
|
||||||
|
// required this.name,
|
||||||
|
// required this.from,
|
||||||
|
// required this.to,
|
||||||
|
// required this.cc,
|
||||||
|
// required this.hash,
|
||||||
|
// required this.subject,
|
||||||
|
// required this.date,
|
||||||
|
// required this.uid,
|
||||||
|
// required this.list,
|
||||||
|
// required this.id,
|
||||||
|
// required this.in_reply_to,
|
||||||
|
// });
|
||||||
|
|
||||||
|
// factory SerializableMessage.fromJson(Map<String, dynamic> json) {
|
||||||
|
// var toList = json['to'] as List;
|
||||||
|
// var ccList = json['cc'] as List;
|
||||||
|
|
||||||
|
// return SerializableMessage(
|
||||||
|
// name: json['name'],
|
||||||
|
// from: json['from'],
|
||||||
|
// // to: json['name', 'address']
|
||||||
|
// to: toList.map((i) => MailAddress.fromJson(i)).toList(),
|
||||||
|
// cc: ccList.map((i) => MailAddress.fromJson(i)).toList(),
|
||||||
|
// // path: json['path'],
|
||||||
|
// hash: json['hash'],
|
||||||
|
// subject: json['subject'],
|
||||||
|
// date: json['date'],
|
||||||
|
// uid: json['uid'],
|
||||||
|
// list: json['list'],
|
||||||
|
// id: json['id'],
|
||||||
|
// in_reply_to: json['in_reply_to'],
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
Loading…
Reference in New Issue
Block a user