fix fav sort

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-04-27 21:30:58 +08:00
parent 524b6bca1c
commit 47e3a47e00
3 changed files with 10 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ import 'package:PiliPlus/http/loading_state.dart';
import 'package:PiliPlus/models_new/fav/fav_detail/media.dart';
import 'package:PiliPlus/pages/fav_detail/controller.dart';
import 'package:PiliPlus/pages/fav_detail/widget/fav_video_card.dart';
import 'package:PiliPlus/utils/extension/iterable_ext.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
@@ -86,8 +87,8 @@ class _FavSortPageState extends State<FavSortPage> {
}
final oldItem = sortList[oldIndex];
final newItem = sortList.elementAtOrNull(
oldIndex > newIndex ? newIndex - 1 : newIndex,
final newItem = sortList.getOrNull(
oldIndex > newIndex ? newIndex - 1 : newIndex, // might be Negative
);
sort.add(
'${newItem == null ? '0:0' : '${newItem.id}:${newItem.type}'}:${oldItem.id}:${oldItem.type}',