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