Refactor imageUrl assignment in updateMangaDetail to handle null and HTTP checks

This commit is contained in:
Moustapha Kodjo Amadou 2025-10-13 13:33:10 +01:00
parent 1f27c129a5
commit 7c47d19a70

View file

@ -8,6 +8,7 @@ import 'package:mangayomi/models/update.dart';
import 'package:mangayomi/models/manga.dart';
import 'package:mangayomi/services/get_detail.dart';
import 'package:mangayomi/utils/extensions/others.dart';
import 'package:mangayomi/utils/extensions/string_extensions.dart';
import 'package:mangayomi/utils/utils.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
@ -42,8 +43,13 @@ Future<dynamic> updateMangaDetail(
[];
final tempName = getManga.name?.trim().trimLeft().trimRight();
final tempLink = getManga.link?.trim().trimLeft().trimRight();
final imgUrl = getManga.imageUrl ?? manga.imageUrl;
manga
..imageUrl = getManga.imageUrl ?? manga.imageUrl
..imageUrl = imgUrl == null
? null
: imgUrl.startsWith('http')
? imgUrl
: '${source.baseUrl ?? ''}/${imgUrl.getUrlWithoutDomain}'
..name = tempName != null && tempName.isNotEmpty ? tempName : manga.name
..genre = (genre.isEmpty ? null : genre) ?? manga.genre ?? []
..author =