mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-11 17:30:00 +02:00
fix(mobile): fix XtreamService cache/URL logic and add tab error handling
This commit is contained in:
1 parent
e4f8ebcf8f
commit
39f4205d68
2 files changed
+51
-5
No files matched your search
@@ -18,14 +18,16 @@ class XtreamService {
|
||||
XtreamService() {
|
||||
_dio = Dio(
|
||||
BaseOptions(
|
||||
connectTimeout: const Duration(seconds: 30),
|
||||
receiveTimeout: const Duration(seconds: 30),
|
||||
connectTimeout: const Duration(seconds: 15),
|
||||
receiveTimeout: const Duration(seconds: 15),
|
||||
sendTimeout: const Duration(seconds: 15),
|
||||
),
|
||||
);
|
||||
|
||||
// Setup caching for API responses
|
||||
// Use MemCacheStore on Web to avoid path errors
|
||||
_cacheOptions = CacheOptions(
|
||||
store: HiveCacheStore('./cache'),
|
||||
store: kIsWeb ? MemCacheStore() : HiveCacheStore('./cache'),
|
||||
policy: CachePolicy.forceCache,
|
||||
maxStale: const Duration(hours: 1),
|
||||
priority: CachePriority.high,
|
||||
@@ -47,11 +49,16 @@ class XtreamService {
|
||||
}
|
||||
if (kIsWeb) {
|
||||
final origin = Uri.base.origin;
|
||||
// If we are developing locally on a different port than the backend
|
||||
if (origin.contains('localhost') && !origin.contains('8089')) {
|
||||
return 'http://localhost:8089';
|
||||
}
|
||||
// On mobile devices, 'localhost' is the device itself.
|
||||
// If origin is localhost but we are on mobile web, it might fail.
|
||||
// We assume the user is accessing via an IP or hostname.
|
||||
return origin;
|
||||
}
|
||||
// Android emulator bridge
|
||||
return 'http://10.0.2.2:8089';
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user