Compare commits

..

No commits in common. "42c97a5f5d1200a5cc9a8d73681a74c7cabca74a" and "51c772a2a119852cf62f1f0b97b1af585c054fbf" have entirely different histories.

5 changed files with 43 additions and 104 deletions

View File

@ -29,7 +29,6 @@ class _ComposeEmailState extends State<ComposeEmail> {
TextEditingController _emailRecipientController = TextEditingController();
TextEditingController _emailSubjectController = TextEditingController();
List<String>? contentOfDraft;
bool isInitialized = false;
@override
void initState() {
@ -54,43 +53,22 @@ class _ComposeEmailState extends State<ComposeEmail> {
_composer = MutableDocumentComposer();
_editor = createDefaultDocumentEditor(
document: _document, composer: _composer);
_emailRecipientController.text = widget.emailDraftID!.to[0].address;
_emailRecipientController.text =
widget.emailDraftID!.to[0].address;
_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
void dispose() {
_editor.dispose();
_emailRecipientController.dispose();
_emailSubjectController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
if (!isInitialized) {
return Center(
child: CircularProgressIndicator(),
);
}
return Positioned(
bottom: 10.0,
right: 10.0,
@ -168,7 +146,7 @@ class _ComposeEmailState extends State<ComposeEmail> {
//here the widget goes
child: SuperEditor(
//make this its own
editor: _editor,
editor: _editor!,
plugins: {MarkdownInlineUpstreamSyntaxPlugin()},
// stylesheet: Stylesheet(

View File

@ -49,39 +49,7 @@ class ApiService {
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(
//populates allEmails, which is the List that contains all the emails in a thread
int threadId,
@ -212,17 +180,16 @@ class ApiService {
return false;
}
// SerializableMessage firstMail = mailsInSerializable[0];
SerializableMessage firstMail = mailsInSerializable[0];
Map<String, String> requestBody = {
'from': fromFolder,
'uid': firstMail.uid.toString(),
'to': "Deleted Crabmail",
};
try {
for (SerializableMessage mail in mailsInSerializable) {
Map<String, String> requestBody = {
'from': fromFolder,
'uid': mail.uid.toString(),
'to': "Deleted Crabmail",
};
var response = await http.post(
var response = await http.post(
url,
headers: {
'Content-Type': 'application/json',
@ -234,7 +201,7 @@ class ApiService {
return true;
} else {
print('error ${response.statusCode} ${response.body}');
}}
}
} catch (e) {
print("failed trying to post move_email, with error: $e");
}
@ -407,8 +374,8 @@ class ApiService {
} catch (e) {
print('_getMDContent caught error: $e');
}
// print("IDS inside fetch md content $IDsString");
// print("inside apiservice $MDofThread");
print("IDS inside fetch md content $IDsString");
return MDofThread;
}
@ -487,8 +454,9 @@ class ApiService {
"subject": subject ?? "Untitled",
"in_reply_to": "",
"messages": [
{"message": emailContent ?? "", "is_html": false}
],
{
"message": emailContent ?? "",
"is_html": false}],
"attachments": [],
"inline_images": [],
};

View File

@ -237,13 +237,13 @@ class _DynamicClassesAugment extends State<EmailToolbar> {
// SizedBox(width: 8),
ElevatedButton(
onPressed: () => AugmentClasses()
.handleCreateLink(context, widget.emails, widget.subject, widget.emails[0]), //need to add the email ids
.handleCreateLink(context, widget.emails, widget.subject),
child: Text('Create Link'),
),
ElevatedButton(
// onPressed: () => localAugment!.handlePaste(context),
onPressed: () =>
AugmentClasses().handlePaste(context),
AugmentClasses().handlePaste(context, widget.emails[0]),
child: Text('Paste Link'),
),
],
@ -552,14 +552,14 @@ class AugmentClasses {
}
_copyLink(String anchor, String target, String format, String viewspecs,
String nameOfDocument, emailID) {
String form = "$anchor < $nameOfDocument, $target :$viewspecs > $emailID";
String nameOfDocument) {
String form = "$anchor < $nameOfDocument, $target :$viewspecs >";
final link = ClipboardData(text: form);
Clipboard.setData(link);
}
Future<void> handleCreateLink(BuildContext context,
List<String> emailsInThread, String nameOfDocument, String emailID) async {
List<String> emailsInThread, String nameOfDocument) async {
print("create link button pressed");
final TextEditingController targetController = TextEditingController();
final TextEditingController anchorController = TextEditingController();
@ -670,9 +670,7 @@ class AugmentClasses {
targetController.text,
format,
viewspecsController.text,
nameOfDocument,
emailID,
),
nameOfDocument),
Navigator.of(context).pop()
},
child: Text("OK")),
@ -684,7 +682,7 @@ class AugmentClasses {
));
}
Future<void> handlePaste(BuildContext context) async {
Future<void> handlePaste(BuildContext context, String emailID) async {
final TextEditingController gotoLink = TextEditingController();
Routinghandler localRouting;
@ -718,16 +716,18 @@ class AugmentClasses {
ElevatedButton(
onPressed: () {
print('pressed');
// i need this shit to be processed into args
print("email_id given $emailID");
Navigator.of(context).pop();
final localRouting =
Routinghandler(gotoLink.text);
Routinghandler(gotoLink.text, emailID);
final String subject =
localRouting.docName; // This is your :subject
final String target =
localRouting.target; // This is your :target
final String viewspecs =
localRouting.viewspecs; // This is your :viewspecs
final String finalEmailID = localRouting.emailID;
final String finalEmailID = emailID;
final encodedSubject = Uri.encodeComponent(subject);
final encodedTarget = Uri.encodeComponent(target);

View File

@ -199,7 +199,6 @@ class _EmailListScreenState extends State<EmailListScreen>
_thisInstance.draftID = email;
_thisInstance.showPersistentWidget(context);
} else {
// print(email)
Navigator.push(
context,
MaterialPageRoute(
@ -297,7 +296,7 @@ class EmailPageState extends State<EmailPage> {
void _fetchEmails() async {
try {
List<GetThreadResponse> fetchedEmails = await apiService
.fetchEmailsFromFolderReversed(widget.selectedFolder, widget.offset);
.fetchEmailsFromFolder(widget.selectedFolder, widget.offset);
if (!mounted) return;
setState(() {

View File

@ -7,7 +7,7 @@ import 'api_service.dart';
import 'structs.dart';
class Routinghandler extends StatefulWidget {
Routinghandler(String link) {
Routinghandler(String link, emailID) {
bool anchorDone = false;
bool docNameDone = false;
@ -16,8 +16,6 @@ class Routinghandler extends StatefulWidget {
bool targetDone = false;
bool emailIdDone = false;
for (int letter = 0; letter < link.length; letter++) {
if (!anchorDone) {
if (link[letter] != '<') {
@ -46,8 +44,6 @@ class Routinghandler extends StatefulWidget {
} else {
viewspecsDone = true;
}
} else if (!emailIdDone) {
emailID += link[letter];
}
}
anchor = anchor.trim();
@ -59,11 +55,11 @@ class Routinghandler extends StatefulWidget {
}
Routinghandler.fromParameters(String anchor, String docName, String target,
String viewspecs, String emailID) {
this.anchor = anchor;
this.docName = docName;
this.viewspecs = viewspecs;
this.target = target;
this.emailID = emailID;
this.anchor = anchor;
this.docName = docName;
this.viewspecs = viewspecs;
this.target = target;
this.emailID = emailID;
}
Routinghandler.copyConstructor(Routinghandler other) {
anchor = other.anchor;
@ -205,16 +201,14 @@ class _RoutingHandlerState extends State<Routinghandler> {
),
),
Expanded(
child: Align(
alignment: Alignment.topLeft,
child: Wrap(
children: [
MarkdownBlock(
data: aug!.children![0]!.children![i]!
.data ??
''),
],
))),
child: Align(
alignment: Alignment.topLeft,
child: Wrap(children: [
MarkdownBlock(
data: aug!.children![0]!.children![i]!.data ?? ''),
],)
)
),
Padding(
padding: const EdgeInsets.fromLTRB(0, 10, 5, 0),
child: Text(