|
@@ -1,12 +1,10 @@
|
|
|
import 'package:crab_ui/structs.dart';
|
|
|
-import 'package:english_words/english_words.dart';
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:http/http.dart' as http;
|
|
|
import 'dart:convert';
|
|
|
import 'dart:ui_web' as ui;
|
|
|
-import 'dart:html' as html;
|
|
|
import 'augment.dart';
|
|
|
-import 'dart:js' as js;
|
|
|
+import 'dart:html' as html;
|
|
|
|
|
|
//data structure
|
|
|
class MailAddress {
|
|
@@ -28,17 +26,15 @@ class MailAddress {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
class EmailPage extends StatefulWidget {
|
|
|
const EmailPage({super.key});
|
|
|
final String title = 'Emails';
|
|
|
|
|
|
@override
|
|
|
- State<EmailPage> createState() => _EmailPageState();
|
|
|
+ State<EmailPage> createState() => EmailPageState();
|
|
|
}
|
|
|
|
|
|
-class _EmailPageState extends State<EmailPage> {
|
|
|
+class EmailPageState extends State<EmailPage> {
|
|
|
List emails = [];
|
|
|
|
|
|
void _displayEmailsFromFolder(String folder) async {
|
|
@@ -46,9 +42,12 @@ class _EmailPageState extends State<EmailPage> {
|
|
|
|
|
|
try {
|
|
|
var url = Uri.http(
|
|
|
- '127.0.0.1:3001', 'sorted_threads_by_date', {'folder': folder});
|
|
|
+ '127.0.0.1:3001', 'sorted_threads_by_date',
|
|
|
+ {'folder': folder,
|
|
|
+ 'limit': '10',
|
|
|
+ 'offset': '0'});
|
|
|
var response = await http.get(url);
|
|
|
-
|
|
|
+ print(response);
|
|
|
if (response.statusCode == 200) {
|
|
|
List json = jsonDecode(response.body);
|
|
|
for (var item in json.take(1)) {
|
|
@@ -74,16 +73,15 @@ class _EmailPageState extends State<EmailPage> {
|
|
|
}
|
|
|
|
|
|
Future<void> fetchThreads(
|
|
|
- int threadId,
|
|
|
- List<GetThreadResponse> allEmails) async {
|
|
|
+ int threadId, List<GetThreadResponse> allEmails) async {
|
|
|
try {
|
|
|
var url =
|
|
|
Uri.http('127.0.0.1:3001', 'get_thread', {'id': threadId.toString()});
|
|
|
var response = await http.get(url);
|
|
|
-
|
|
|
+
|
|
|
if (response.statusCode == 200) {
|
|
|
Map<String, dynamic> messagesJson = jsonDecode(response.body);
|
|
|
- GetThreadResponse threadResponse =
|
|
|
+ GetThreadResponse threadResponse =
|
|
|
GetThreadResponse.fromJson(messagesJson);
|
|
|
|
|
|
allEmails.add(threadResponse);
|
|
@@ -101,6 +99,7 @@ class _EmailPageState extends State<EmailPage> {
|
|
|
""";
|
|
|
|
|
|
try {
|
|
|
+ //attaches email after email from a thread
|
|
|
for (var id in IDs) {
|
|
|
var url = Uri.http('127.0.0.1:3001', 'email', {'id': id});
|
|
|
|
|
@@ -108,6 +107,7 @@ class _EmailPageState extends State<EmailPage> {
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
content += response.body;
|
|
|
+ content += "<p>new shit</p><br><br><br>";
|
|
|
}
|
|
|
}
|
|
|
} catch (e) {
|
|
@@ -116,7 +116,7 @@ class _EmailPageState extends State<EmailPage> {
|
|
|
return content;
|
|
|
}
|
|
|
|
|
|
- Future<List<Widget>> _getDrawerItems() async {
|
|
|
+ Future<List<Widget>> getDrawerItems(BuildContext context) async {
|
|
|
List<String> drawerItems = [];
|
|
|
|
|
|
try {
|
|
@@ -124,7 +124,7 @@ class _EmailPageState extends State<EmailPage> {
|
|
|
var response = await http.get(url);
|
|
|
drawerItems = List<String>.from(json.decode(response.body));
|
|
|
} catch (e) {
|
|
|
- print('_getDrawerItems caught error: $e');
|
|
|
+ print('getDrawerItems caught error: $e');
|
|
|
}
|
|
|
|
|
|
List<Widget> drawerWidgets = [];
|
|
@@ -155,7 +155,7 @@ class _EmailPageState extends State<EmailPage> {
|
|
|
drawer: Drawer(
|
|
|
child: FutureBuilder<List<Widget>>(
|
|
|
future:
|
|
|
- _getDrawerItems(), // call the async function to get the future
|
|
|
+ getDrawerItems(context), // call the async function to get the future
|
|
|
builder:
|
|
|
(BuildContext context, AsyncSnapshot<List<Widget>> snapshot) {
|
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
@@ -237,8 +237,7 @@ class EmailListScreen extends StatelessWidget {
|
|
|
subject: subject,
|
|
|
date: date,
|
|
|
id: id,
|
|
|
- )
|
|
|
- ),
|
|
|
+ )),
|
|
|
);
|
|
|
});
|
|
|
},
|