Compare commits
4 Commits
51c772a2a1
...
42c97a5f5d
Author | SHA1 | Date | |
---|---|---|---|
42c97a5f5d | |||
dea8f03fe1 | |||
2ce8af1608 | |||
de7758102b |
@ -29,6 +29,7 @@ class _ComposeEmailState extends State<ComposeEmail> {
|
|||||||
TextEditingController _emailRecipientController = TextEditingController();
|
TextEditingController _emailRecipientController = TextEditingController();
|
||||||
TextEditingController _emailSubjectController = TextEditingController();
|
TextEditingController _emailSubjectController = TextEditingController();
|
||||||
List<String>? contentOfDraft;
|
List<String>? contentOfDraft;
|
||||||
|
bool isInitialized = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@ -53,22 +54,43 @@ class _ComposeEmailState extends State<ComposeEmail> {
|
|||||||
_composer = MutableDocumentComposer();
|
_composer = MutableDocumentComposer();
|
||||||
_editor = createDefaultDocumentEditor(
|
_editor = createDefaultDocumentEditor(
|
||||||
document: _document, composer: _composer);
|
document: _document, composer: _composer);
|
||||||
_emailRecipientController.text =
|
_emailRecipientController.text = widget.emailDraftID!.to[0].address;
|
||||||
widget.emailDraftID!.to[0].address;
|
|
||||||
_emailSubjectController.text = widget.emailDraftID!.subject;
|
_emailSubjectController.text = widget.emailDraftID!.subject;
|
||||||
|
isInitialized = true;
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
setState(() {
|
||||||
|
_document = MutableDocument(nodes: [
|
||||||
|
ParagraphNode(
|
||||||
|
id: Editor.createNodeId(),
|
||||||
|
text: AttributedText(""),
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
_composer = MutableDocumentComposer();
|
||||||
|
_editor = createDefaultDocumentEditor(
|
||||||
|
document: _document, composer: _composer);
|
||||||
|
isInitialized = true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
_editor.dispose();
|
_editor.dispose();
|
||||||
|
_emailRecipientController.dispose();
|
||||||
|
_emailSubjectController.dispose();
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
if (!isInitialized) {
|
||||||
|
return Center(
|
||||||
|
child: CircularProgressIndicator(),
|
||||||
|
);
|
||||||
|
}
|
||||||
return Positioned(
|
return Positioned(
|
||||||
bottom: 10.0,
|
bottom: 10.0,
|
||||||
right: 10.0,
|
right: 10.0,
|
||||||
@ -146,7 +168,7 @@ class _ComposeEmailState extends State<ComposeEmail> {
|
|||||||
//here the widget goes
|
//here the widget goes
|
||||||
child: SuperEditor(
|
child: SuperEditor(
|
||||||
//make this its own
|
//make this its own
|
||||||
editor: _editor!,
|
editor: _editor,
|
||||||
plugins: {MarkdownInlineUpstreamSyntaxPlugin()},
|
plugins: {MarkdownInlineUpstreamSyntaxPlugin()},
|
||||||
|
|
||||||
// stylesheet: Stylesheet(
|
// stylesheet: Stylesheet(
|
||||||
|
@ -49,7 +49,39 @@ class ApiService {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Future<List<GetThreadResponse>> fetchEmailsFromFolderReversed(
|
||||||
|
String folder, int pagenitaion) async {
|
||||||
|
try {
|
||||||
|
var url = Uri.http('$ip:$port', 'sorted_threads_by_date_current', {
|
||||||
|
'folder': folder,
|
||||||
|
'limit': '50',
|
||||||
|
'offset': pagenitaion.toString(),
|
||||||
|
});
|
||||||
|
|
||||||
|
var response = await http.get(url);
|
||||||
|
List<GetThreadResponse> allEmails = [];
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
List json = jsonDecode(response.body);
|
||||||
|
for (var item in json) {
|
||||||
|
//each item in the json is a date
|
||||||
|
if (item.length > 1 && item[0] is String && item[1] is List) {
|
||||||
|
List<int> threadIDs = List<int>.from(item[1]);
|
||||||
|
for (var threadId in threadIDs) {
|
||||||
|
await fetchThreads(threadId, allEmails);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
currFolder = folder;
|
||||||
|
return allEmails;
|
||||||
|
} else {
|
||||||
|
throw Exception('Failed to load threads');
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('_displayEmailsFromFolder caught error: $e');
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
Future<void> fetchThreads(
|
Future<void> fetchThreads(
|
||||||
//populates allEmails, which is the List that contains all the emails in a thread
|
//populates allEmails, which is the List that contains all the emails in a thread
|
||||||
int threadId,
|
int threadId,
|
||||||
@ -180,16 +212,17 @@ class ApiService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SerializableMessage firstMail = mailsInSerializable[0];
|
// SerializableMessage firstMail = mailsInSerializable[0];
|
||||||
|
|
||||||
Map<String, String> requestBody = {
|
|
||||||
'from': fromFolder,
|
|
||||||
'uid': firstMail.uid.toString(),
|
|
||||||
'to': "Deleted Crabmail",
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var response = await http.post(
|
for (SerializableMessage mail in mailsInSerializable) {
|
||||||
|
Map<String, String> requestBody = {
|
||||||
|
'from': fromFolder,
|
||||||
|
'uid': mail.uid.toString(),
|
||||||
|
'to': "Deleted Crabmail",
|
||||||
|
};
|
||||||
|
var response = await http.post(
|
||||||
url,
|
url,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@ -201,7 +234,7 @@ class ApiService {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
print('error ${response.statusCode} ${response.body}');
|
print('error ${response.statusCode} ${response.body}');
|
||||||
}
|
}}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("failed trying to post move_email, with error: $e");
|
print("failed trying to post move_email, with error: $e");
|
||||||
}
|
}
|
||||||
@ -374,8 +407,8 @@ class ApiService {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('_getMDContent caught error: $e');
|
print('_getMDContent caught error: $e');
|
||||||
}
|
}
|
||||||
print("IDS inside fetch md content $IDsString");
|
// print("IDS inside fetch md content $IDsString");
|
||||||
|
// print("inside apiservice $MDofThread");
|
||||||
return MDofThread;
|
return MDofThread;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,9 +487,8 @@ class ApiService {
|
|||||||
"subject": subject ?? "Untitled",
|
"subject": subject ?? "Untitled",
|
||||||
"in_reply_to": "",
|
"in_reply_to": "",
|
||||||
"messages": [
|
"messages": [
|
||||||
{
|
{"message": emailContent ?? "", "is_html": false}
|
||||||
"message": emailContent ?? "",
|
],
|
||||||
"is_html": false}],
|
|
||||||
"attachments": [],
|
"attachments": [],
|
||||||
"inline_images": [],
|
"inline_images": [],
|
||||||
};
|
};
|
||||||
|
@ -237,13 +237,13 @@ class _DynamicClassesAugment extends State<EmailToolbar> {
|
|||||||
// SizedBox(width: 8),
|
// SizedBox(width: 8),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () => AugmentClasses()
|
onPressed: () => AugmentClasses()
|
||||||
.handleCreateLink(context, widget.emails, widget.subject),
|
.handleCreateLink(context, widget.emails, widget.subject, widget.emails[0]), //need to add the email ids
|
||||||
child: Text('Create Link'),
|
child: Text('Create Link'),
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
// onPressed: () => localAugment!.handlePaste(context),
|
// onPressed: () => localAugment!.handlePaste(context),
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
AugmentClasses().handlePaste(context, widget.emails[0]),
|
AugmentClasses().handlePaste(context),
|
||||||
child: Text('Paste Link'),
|
child: Text('Paste Link'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@ -552,14 +552,14 @@ class AugmentClasses {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_copyLink(String anchor, String target, String format, String viewspecs,
|
_copyLink(String anchor, String target, String format, String viewspecs,
|
||||||
String nameOfDocument) {
|
String nameOfDocument, emailID) {
|
||||||
String form = "$anchor < $nameOfDocument, $target :$viewspecs >";
|
String form = "$anchor < $nameOfDocument, $target :$viewspecs > $emailID";
|
||||||
final link = ClipboardData(text: form);
|
final link = ClipboardData(text: form);
|
||||||
Clipboard.setData(link);
|
Clipboard.setData(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> handleCreateLink(BuildContext context,
|
Future<void> handleCreateLink(BuildContext context,
|
||||||
List<String> emailsInThread, String nameOfDocument) async {
|
List<String> emailsInThread, String nameOfDocument, String emailID) async {
|
||||||
print("create link button pressed");
|
print("create link button pressed");
|
||||||
final TextEditingController targetController = TextEditingController();
|
final TextEditingController targetController = TextEditingController();
|
||||||
final TextEditingController anchorController = TextEditingController();
|
final TextEditingController anchorController = TextEditingController();
|
||||||
@ -670,7 +670,9 @@ class AugmentClasses {
|
|||||||
targetController.text,
|
targetController.text,
|
||||||
format,
|
format,
|
||||||
viewspecsController.text,
|
viewspecsController.text,
|
||||||
nameOfDocument),
|
nameOfDocument,
|
||||||
|
emailID,
|
||||||
|
),
|
||||||
Navigator.of(context).pop()
|
Navigator.of(context).pop()
|
||||||
},
|
},
|
||||||
child: Text("OK")),
|
child: Text("OK")),
|
||||||
@ -682,7 +684,7 @@ class AugmentClasses {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> handlePaste(BuildContext context, String emailID) async {
|
Future<void> handlePaste(BuildContext context) async {
|
||||||
final TextEditingController gotoLink = TextEditingController();
|
final TextEditingController gotoLink = TextEditingController();
|
||||||
|
|
||||||
Routinghandler localRouting;
|
Routinghandler localRouting;
|
||||||
@ -716,18 +718,16 @@ class AugmentClasses {
|
|||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
print('pressed');
|
print('pressed');
|
||||||
// i need this shit to be processed into args
|
|
||||||
print("email_id given $emailID");
|
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
final localRouting =
|
final localRouting =
|
||||||
Routinghandler(gotoLink.text, emailID);
|
Routinghandler(gotoLink.text);
|
||||||
final String subject =
|
final String subject =
|
||||||
localRouting.docName; // This is your :subject
|
localRouting.docName; // This is your :subject
|
||||||
final String target =
|
final String target =
|
||||||
localRouting.target; // This is your :target
|
localRouting.target; // This is your :target
|
||||||
final String viewspecs =
|
final String viewspecs =
|
||||||
localRouting.viewspecs; // This is your :viewspecs
|
localRouting.viewspecs; // This is your :viewspecs
|
||||||
final String finalEmailID = emailID;
|
final String finalEmailID = localRouting.emailID;
|
||||||
|
|
||||||
final encodedSubject = Uri.encodeComponent(subject);
|
final encodedSubject = Uri.encodeComponent(subject);
|
||||||
final encodedTarget = Uri.encodeComponent(target);
|
final encodedTarget = Uri.encodeComponent(target);
|
||||||
|
@ -199,6 +199,7 @@ class _EmailListScreenState extends State<EmailListScreen>
|
|||||||
_thisInstance.draftID = email;
|
_thisInstance.draftID = email;
|
||||||
_thisInstance.showPersistentWidget(context);
|
_thisInstance.showPersistentWidget(context);
|
||||||
} else {
|
} else {
|
||||||
|
// print(email)
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
@ -296,7 +297,7 @@ class EmailPageState extends State<EmailPage> {
|
|||||||
void _fetchEmails() async {
|
void _fetchEmails() async {
|
||||||
try {
|
try {
|
||||||
List<GetThreadResponse> fetchedEmails = await apiService
|
List<GetThreadResponse> fetchedEmails = await apiService
|
||||||
.fetchEmailsFromFolder(widget.selectedFolder, widget.offset);
|
.fetchEmailsFromFolderReversed(widget.selectedFolder, widget.offset);
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -7,7 +7,7 @@ import 'api_service.dart';
|
|||||||
import 'structs.dart';
|
import 'structs.dart';
|
||||||
|
|
||||||
class Routinghandler extends StatefulWidget {
|
class Routinghandler extends StatefulWidget {
|
||||||
Routinghandler(String link, emailID) {
|
Routinghandler(String link) {
|
||||||
bool anchorDone = false;
|
bool anchorDone = false;
|
||||||
|
|
||||||
bool docNameDone = false;
|
bool docNameDone = false;
|
||||||
@ -16,6 +16,8 @@ class Routinghandler extends StatefulWidget {
|
|||||||
|
|
||||||
bool targetDone = false;
|
bool targetDone = false;
|
||||||
|
|
||||||
|
bool emailIdDone = false;
|
||||||
|
|
||||||
for (int letter = 0; letter < link.length; letter++) {
|
for (int letter = 0; letter < link.length; letter++) {
|
||||||
if (!anchorDone) {
|
if (!anchorDone) {
|
||||||
if (link[letter] != '<') {
|
if (link[letter] != '<') {
|
||||||
@ -44,6 +46,8 @@ class Routinghandler extends StatefulWidget {
|
|||||||
} else {
|
} else {
|
||||||
viewspecsDone = true;
|
viewspecsDone = true;
|
||||||
}
|
}
|
||||||
|
} else if (!emailIdDone) {
|
||||||
|
emailID += link[letter];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
anchor = anchor.trim();
|
anchor = anchor.trim();
|
||||||
@ -55,11 +59,11 @@ class Routinghandler extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
Routinghandler.fromParameters(String anchor, String docName, String target,
|
Routinghandler.fromParameters(String anchor, String docName, String target,
|
||||||
String viewspecs, String emailID) {
|
String viewspecs, String emailID) {
|
||||||
this.anchor = anchor;
|
this.anchor = anchor;
|
||||||
this.docName = docName;
|
this.docName = docName;
|
||||||
this.viewspecs = viewspecs;
|
this.viewspecs = viewspecs;
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.emailID = emailID;
|
this.emailID = emailID;
|
||||||
}
|
}
|
||||||
Routinghandler.copyConstructor(Routinghandler other) {
|
Routinghandler.copyConstructor(Routinghandler other) {
|
||||||
anchor = other.anchor;
|
anchor = other.anchor;
|
||||||
@ -201,14 +205,16 @@ class _RoutingHandlerState extends State<Routinghandler> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Align(
|
child: Align(
|
||||||
alignment: Alignment.topLeft,
|
alignment: Alignment.topLeft,
|
||||||
child: Wrap(children: [
|
child: Wrap(
|
||||||
MarkdownBlock(
|
children: [
|
||||||
data: aug!.children![0]!.children![i]!.data ?? ''),
|
MarkdownBlock(
|
||||||
],)
|
data: aug!.children![0]!.children![i]!
|
||||||
)
|
.data ??
|
||||||
),
|
''),
|
||||||
|
],
|
||||||
|
))),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.fromLTRB(0, 10, 5, 0),
|
padding: const EdgeInsets.fromLTRB(0, 10, 5, 0),
|
||||||
child: Text(
|
child: Text(
|
||||||
|
Loading…
Reference in New Issue
Block a user