rename and delete api calls

This commit is contained in:
Juan Marulanda De Los Rios 2025-04-24 17:01:19 -04:00
parent c09f4e7a11
commit a65c973dc7

View File

@ -122,8 +122,8 @@ class ApiService {
if (response.statusCode == 200) { if (response.statusCode == 200) {
content += response.body; content += response.body;
try { try {
List<AttachmentInfo> attachments = await getAttachmentsInfo( List<AttachmentInfo> attachments =
emailFolder, id); await getAttachmentsInfo(emailFolder, id);
for (var attachment in attachments) { for (var attachment in attachments) {
//TODO: for each attachment creaate at the bottom a widget for each individual one //TODO: for each attachment creaate at the bottom a widget for each individual one
threadAttachments threadAttachments
@ -182,6 +182,31 @@ class ApiService {
} }
} }
Future<void> renameFolder(String oldFolder, String newFolder) async {
var url = Uri.http('$ip:$port', 'rename_folder');
Map<String, String> requestBody = {
'old_name': oldFolder,
'new_name': newFolder,
};
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<void> deleteFolder(String folderName) async { Future<void> deleteFolder(String folderName) async {
var url = Uri.http('$ip:$port', 'delete_folder'); var url = Uri.http('$ip:$port', 'delete_folder');
@ -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) //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 // if it was multiple iframes then the scrolling to jump would not work as expected
print("marker called"); print("marker called");
// JavaScript code embedded as a string // JavaScript code embedded as a string
String jsCode = ''' String jsCode = '''