From 1fb4cfd64c75c893f45bc6d439d803cf3befcef1 Mon Sep 17 00:00:00 2001 From: juan Date: Wed, 18 Jun 2025 16:35:16 -0400 Subject: [PATCH] modified for using the markdown --- lib/collapsableEmailsStub.dart | 6 +++--- lib/collapsableEmailsWeb.dart | 29 ++++++++++++++++++----------- lib/email.dart | 3 ++- lib/emailViewWeb.dart | 3 ++- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/lib/collapsableEmailsStub.dart b/lib/collapsableEmailsStub.dart index 7c89a88..dd9168f 100644 --- a/lib/collapsableEmailsStub.dart +++ b/lib/collapsableEmailsStub.dart @@ -3,13 +3,13 @@ import 'package:flutter/material.dart'; class CollapsableEmails extends StatefulWidget { final List thread; // email id's in the form xyz@gmail.com - final List threadHTML; + final List threadMarkdown; final String threadIDs; CollapsableEmails( {required this.thread, - required this.threadHTML, - required this.threadIDs}); + required this.threadMarkdown, + required this.threadIDs, String? targetJumpNumbering, String? targetViewspecs}); @override State createState() => _CollapsableEmailsState(); diff --git a/lib/collapsableEmailsWeb.dart b/lib/collapsableEmailsWeb.dart index 7422d9e..1183259 100644 --- a/lib/collapsableEmailsWeb.dart +++ b/lib/collapsableEmailsWeb.dart @@ -1,3 +1,4 @@ +import 'package:english_words/english_words.dart'; import 'package:flutter/material.dart'; import 'api_service.dart'; import 'structs.dart'; @@ -7,14 +8,16 @@ import 'package:markdown/markdown.dart' as md; class CollapsableEmails extends StatefulWidget { final List thread; // email id's in the form xyz@gmail.com - final List threadHTML; + // final List threadHTML; to be replaced with the MD + final List threadMarkdown; final String threadIDs; final String? targetJumpNumbering; final String? targetViewspecs; const CollapsableEmails({ required this.thread, - required this.threadHTML, + // required this.threadHTML, + required this.threadMarkdown, required this.threadIDs, this.targetJumpNumbering, this.targetViewspecs, @@ -63,9 +66,9 @@ class _CollapsableEmailsState extends State { super.initState(); threadNodes = []; currentZoomTree = []; - _markdownConverter(); + // _markdownConverter(); _serializableData(widget.threadIDs); // this - _markdown2Tree(allMarkdown); + _markdown2Tree(widget.threadMarkdown); } @override @@ -87,12 +90,16 @@ class _CollapsableEmailsState extends State { super.dispose(); } - void _markdownConverter() async { - for (int email = 0; email < widget.threadHTML.length; email++) { - String markdown = html2md.convert(widget.threadHTML[email]); - allMarkdown.add(markdown); - } - } + // void _markdownConverter() async { + // // to list of markdown + // // for (int email = 0; email < widget.threadHTML.length; email++) { + // // String markdown = html2md.convert(widget.threadHTML[email]); + // // allMarkdown.add(markdown); + // // } + // for (int email = 0; email < widget.threadMarkdown.length; email++) { + // allMarkdown.add(email); + // } + // } void _add2Tree(AugmentTree tree, md.Element node2add) { // adds node to its corresponding place @@ -369,7 +376,7 @@ class _CollapsableEmailsState extends State { rightNumbering = !rightNumbering; }); } - if (viewspecsQuery.contrains('w')) { + if (viewspecsQuery.contains('w')) { setState(() { showWhole = true; }); diff --git a/lib/email.dart b/lib/email.dart index ff4d600..0b1ded3 100644 --- a/lib/email.dart +++ b/lib/email.dart @@ -140,7 +140,8 @@ class EmailPageState extends State { return Scaffold( body: EmailListScreen( emails: emails, - getEmailContent: apiService.fetchEmailContent, + // getEmailContent: apiService.fetchEmailContent, + getEmailContent: apiService.fetchMarkdownContent, folder: widget.selectedFolder, //try to grab from it directly ), ); diff --git a/lib/emailViewWeb.dart b/lib/emailViewWeb.dart index df50e6d..ceb4ef1 100644 --- a/lib/emailViewWeb.dart +++ b/lib/emailViewWeb.dart @@ -128,7 +128,8 @@ class _EmailViewState extends State { child: CollapsableEmails( //change here thread: widget.messages, //this wont work in serializable - threadHTML: widget.emailContent, + // threadHTML: widget.emailContent, // old html + threadMarkdown: widget.emailContent, threadIDs: widget.id, targetJumpNumbering: _targetJumpNumbering, targetViewspecs: _targetViewspecs,