making ips and ports dynamic on the login

This commit is contained in:
Juan Marulanda De Los Rios 2024-12-18 23:41:17 -05:00
parent d32fadfdc5
commit 7423135fea

View File

@ -10,10 +10,13 @@ import 'augment.dart';
import 'dart:html' as html;
class ApiService {
static String ip = "";
static String port = "";
Future<List<GetThreadResponse>> fetchEmailsFromFolder(
String folder, int pagenitaion) async {
// print(ip + " " + port);
try {
var url = Uri.http('0.0.0.0:3001', 'sorted_threads_by_date', {
var url = Uri.http('$ip:$port', 'sorted_threads_by_date', {
'folder': folder,
'limit': '50',
'offset': pagenitaion.toString(),
@ -49,7 +52,7 @@ class ApiService {
List<GetThreadResponse> allEmails) async {
try {
var url =
Uri.http('0.0.0.0:3001', 'get_thread', {'id': threadId.toString()});
Uri.http('$ip:$port', 'get_thread', {'id': threadId.toString()});
var response = await http.get(url);
if (response.statusCode == 200) {
@ -70,7 +73,7 @@ class ApiService {
Future<List<SerializableMessage>> sonicSearch(
String list, int limit, int offset, String query) async {
try {
var url = Uri.http('0.0.0.0:3001', 'search_emails', {
var url = Uri.http('$ip:$port', 'search_emails', {
'list': list,
'limit': limit.toString(),
'offset': offset.toString(),
@ -101,7 +104,7 @@ class ApiService {
try {
//attaches email after email from a thread
for (var id in IDs) {
var url = Uri.http('0.0.0.0:3001', 'email', {'id': id});
var url = Uri.http('$ip:$port', 'email', {'id': id});
var response = await http.get(url);
@ -128,7 +131,7 @@ class ApiService {
Future<List<String>> fetchFolders() async {
try {
var url = Uri.http('0.0.0.0:3001', 'folders');
var url = Uri.http('$ip:$port', 'folders');
var response = await http.get(url);
return List<String>.from(json.decode(response.body));
} catch (e) {
@ -138,7 +141,7 @@ class ApiService {
}
Future<void> createFolder(String folderName) async {
var url = Uri.http('0.0.0.0:3001', 'create_folder');
var url = Uri.http('$ip:$port', 'create_folder');
Map<String, String> requestBody = {'name': folderName};
@ -161,7 +164,7 @@ class ApiService {
}
Future<void> deleteFolder(String folderName) async {
var url = Uri.http('0.0.0.0:3001', 'delete_folder');
var url = Uri.http('$ip:$port', 'delete_folder');
Map<String, String> requestBody = {'name': folderName};
@ -197,7 +200,7 @@ class ApiService {
Future<List<AttachmentInfo>> getAttachmentsInfo(
String folder, String email_id) async {
try {
var url = Uri.http('0.0.0.0:3001', 'get_attachments_info',
var url = Uri.http('127.0.0.1:3001', 'get_attachments_info',
{'folder': folder, 'email_id': email_id});
print(url);
var response = await http.get(url);