mirror of
https://github.com/yaobiao131/downkyicore.git
synced 2025-08-10 00:52:31 +00:00
feat: 完善观看历史无限滚动功能
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Xaml.Interactivity;
|
||||
using ImTools;
|
||||
|
||||
namespace DownKyi.CustomAction;
|
||||
|
||||
@@ -51,6 +52,7 @@ public class IncrementalLoadingBehavior<T>: Behavior<ListBox>
|
||||
|
||||
isLoading = true;
|
||||
var items = await LoadPageFunc(currentPage);
|
||||
if(items == null || items.Length == 0) return;
|
||||
foreach (var item in items)
|
||||
{
|
||||
AssociatedObject.Items.Add(item);
|
||||
|
||||
@@ -259,19 +259,30 @@ public class ViewMyHistoryViewModel : ViewModelBase
|
||||
int startIndex = (page - 1) * VideoNumberInPage;
|
||||
return Task.Run<HistoryMedia[]>(() =>
|
||||
{
|
||||
var result = History.GetHistory(_nextMax, _nextViewAt, VideoNumberInPage);
|
||||
foreach (var item in result.List)
|
||||
App.PropertyChangeAsync(() =>
|
||||
{
|
||||
var history = Convert(item, EventAggregator);
|
||||
if (history != null)
|
||||
LoadingVisibility = true;
|
||||
});
|
||||
var result = History.GetHistory(_nextMax, _nextViewAt, VideoNumberInPage);
|
||||
if (result?.List?.Count > 0)
|
||||
{
|
||||
foreach (var item in result.List)
|
||||
{
|
||||
Medias.Add(history);
|
||||
var history = Convert(item, EventAggregator);
|
||||
if (history != null)
|
||||
{
|
||||
Medias.Add(history);
|
||||
}
|
||||
}
|
||||
App.PropertyChangeAsync(() =>
|
||||
{
|
||||
LoadingVisibility = false;
|
||||
});
|
||||
_nextMax = result.Cursor.Max;
|
||||
_nextViewAt = result.Cursor.ViewAt;
|
||||
return Medias.Skip(startIndex).Take(VideoNumberInPage).ToArray();
|
||||
}
|
||||
|
||||
_nextMax = result.Cursor.Max;
|
||||
_nextViewAt = result.Cursor.ViewAt;
|
||||
return Medias.Skip(startIndex).Take(VideoNumberInPage).ToArray();
|
||||
return Array.Empty<HistoryMedia>();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user