shorter time to collect threads due to new endpoint, and fixed the view for emails (needs improvement tho)
This commit is contained in:
		
							parent
							
								
									04129f6da0
								
							
						
					
					
						commit
						254972d2af
					
				
					 1 changed files with 13 additions and 11 deletions
				
			
		| 
						 | 
					@ -124,9 +124,9 @@ class _EmailPageState extends State<EmailPage> {
 | 
				
			||||||
    setState(() {
 | 
					    setState(() {
 | 
				
			||||||
      emails = allEmails;
 | 
					      emails = allEmails;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    print(emails[0]);
 | 
					    // print(emails[0]);
 | 
				
			||||||
    // Print allEmails to debug its structure
 | 
					    // Print allEmails to debug its structure
 | 
				
			||||||
    print("allEmails: ${allEmails[0].messages}");
 | 
					    // print("allEmails: ${allEmails[0].messages}");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Convert allEmails to a list
 | 
					    // Convert allEmails to a list
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
| 
						 | 
					@ -188,23 +188,24 @@ class _EmailPageState extends State<EmailPage> {
 | 
				
			||||||
  //   }
 | 
					  //   }
 | 
				
			||||||
  // }
 | 
					  // }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Future<String> _getEmailContent(String id) async {
 | 
					  Future<String> _getEmailContent(List<String> IDs) async {
 | 
				
			||||||
    String content = r"""
 | 
					    String content = r"""
 | 
				
			||||||
 | 
					 | 
				
			||||||
    """;
 | 
					    """;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      var url = Uri.http('127.0.0.1:3001', 'email', {'id': id});
 | 
					      for (var id in IDs) {
 | 
				
			||||||
 | 
					        var url = Uri.http('127.0.0.1:3001', 'email', {'id': id});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      var response = await http.get(url);
 | 
					        var response = await http.get(url);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (response.statusCode == 200) {
 | 
					        if (response.statusCode == 200) {
 | 
				
			||||||
        content = response.body;
 | 
					          content += response.body;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    } catch (e) {
 | 
					    } catch (e) {
 | 
				
			||||||
      print('_getEmailContent caught error: $e');
 | 
					      print('_getEmailContent caught error: $e');
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    print(content);
 | 
				
			||||||
    return content;
 | 
					    return content;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -280,7 +281,7 @@ class EmailListScreen extends StatelessWidget {
 | 
				
			||||||
  //this is the bulding of the drawer with all emails
 | 
					  //this is the bulding of the drawer with all emails
 | 
				
			||||||
  // try to only get the subject and id, date, sender to make it faster
 | 
					  // try to only get the subject and id, date, sender to make it faster
 | 
				
			||||||
  final List emails;
 | 
					  final List emails;
 | 
				
			||||||
  final Future<String> Function(String) getEmailContent;
 | 
					  final Future<String> Function(List<String>) getEmailContent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  EmailListScreen({
 | 
					  EmailListScreen({
 | 
				
			||||||
    required this.emails,
 | 
					    required this.emails,
 | 
				
			||||||
| 
						 | 
					@ -309,7 +310,8 @@ class EmailListScreen extends StatelessWidget {
 | 
				
			||||||
              //here we assign each part of json to a var, this could be changed so it only happens,
 | 
					              //here we assign each part of json to a var, this could be changed so it only happens,
 | 
				
			||||||
              // when clicking on email for modularity
 | 
					              // when clicking on email for modularity
 | 
				
			||||||
              onTap: () async {
 | 
					              onTap: () async {
 | 
				
			||||||
                String emailContent = await getEmailContent(emails[index].id);
 | 
					                String emailContent =
 | 
				
			||||||
 | 
					                    await getEmailContent(emails[index].messages);
 | 
				
			||||||
                String messages = emails[index].messages.toString();
 | 
					                String messages = emails[index].messages.toString();
 | 
				
			||||||
                String fromName = emails[index].from_name.toString();
 | 
					                String fromName = emails[index].from_name.toString();
 | 
				
			||||||
                String fromAddress = emails[index].from_address.toString();
 | 
					                String fromAddress = emails[index].from_address.toString();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue