From a65c973dc74be72457fb4422f37971362045922c Mon Sep 17 00:00:00 2001 From: juan Date: Thu, 24 Apr 2025 17:01:19 -0400 Subject: [PATCH] rename and delete api calls --- lib/api_service.dart | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/api_service.dart b/lib/api_service.dart index 1777c9c..37b6736 100644 --- a/lib/api_service.dart +++ b/lib/api_service.dart @@ -122,8 +122,8 @@ class ApiService { if (response.statusCode == 200) { content += response.body; try { - List attachments = await getAttachmentsInfo( - emailFolder, id); + List attachments = + await getAttachmentsInfo(emailFolder, id); for (var attachment in attachments) { //TODO: for each attachment creaate at the bottom a widget for each individual one threadAttachments @@ -164,6 +164,31 @@ class ApiService { Map requestBody = {'name': folderName}; + try { + var response = await http.post( + url, + headers: { + 'Content-Type': 'application/json', + }, + body: jsonEncode(requestBody), + ); + if (response.statusCode == 200) { + print('response body: ${response.body}'); + } else { + print('Error: ${response.statusCode}, response body: ${response.body}'); + } + } catch (e) { + print('error making post req: $e'); + } + } + + Future renameFolder(String oldFolder, String newFolder) async { + var url = Uri.http('$ip:$port', 'rename_folder'); + Map requestBody = { + 'old_name': oldFolder, + 'new_name': newFolder, + }; + try { var response = await http.post( url, @@ -268,7 +293,6 @@ class ApiService { //leads to problems as for a) the html is added one right after the other in one iframe, b) // if it was multiple iframes then the scrolling to jump would not work as expected - print("marker called"); // JavaScript code embedded as a string String jsCode = ''' @@ -379,7 +403,7 @@ class _EmailViewState extends State { String currentContent = widget.emailContent; viewTypeId = "iframe-${DateTime.now().millisecondsSinceEpoch}"; _registerViewFactory(currentContent); - _markerPositionsFuture = ApiService().getMarkerPosition(); + _markerPositionsFuture = ApiService().getMarkerPosition(); } void _registerViewFactory(String currentContent) {