[Bugfix] Fixed refreshing details screens

This commit is contained in:
PartyDonut 2024-10-06 19:35:57 +02:00
parent 8bda03ee2c
commit aaa6a737cb
4 changed files with 10 additions and 13 deletions

View file

@ -18,14 +18,15 @@ class MovieDetails extends _$MovieDetails {
Future<Response?> fetchDetails(ItemBaseModel item) async {
try {
if (item is MovieModel && state == null) {
state = item;
if (item is MovieModel) {
state = state ?? item;
}
MovieModel? newState;
final response = await api.usersUserIdItemsItemIdGet(itemId: item.id);
if (response.body == null) return null;
state = response.bodyOrThrow as MovieModel;
newState = (response.bodyOrThrow as MovieModel).copyWith(related: state?.related);
final related = await ref.read(relatedUtilityProvider).relatedContent(item.id);
state = state?.copyWith(related: related.body);
state = newState.copyWith(related: related.body);
return null;
} catch (e) {
_tryToCreateOfflineState(item);