fix(media): parse responses before caching

This commit is contained in:
edde746
2026-07-25 17:38:09 +02:00
parent 516bd69c19
commit 12b826faff
3 changed files with 52 additions and 3 deletions
+4 -2
View File
@@ -750,10 +750,11 @@ mixin MediaServerCacheMixin implements MediaServerClient {
try {
final response = await networkCall();
throwIfHttpError(response);
final parsed = parseResponse(response);
if (cacheResponse) {
await _putCacheResponse(cacheScope, cacheKey, response.data);
}
return parseResponse(response);
return parsed;
} catch (e) {
if (shouldFallback != null && !shouldFallback(e)) rethrow;
appLogger.w('Network request failed for $cacheKey, trying cache', error: e);
@@ -784,10 +785,11 @@ mixin MediaServerCacheMixin implements MediaServerClient {
if (isOfflineMode) return null;
final response = await networkCall();
throwIfHttpError(response);
final parsed = parseResponse(response);
if (cacheResponse) {
await _putCacheResponse(cacheScope, cacheKey, response.data);
}
return parseResponse(response);
return parsed;
}
Future<void> _putCacheResponse(ServerId cacheScope, String cacheKey, dynamic data) async {