|
@@ -4,6 +4,7 @@ using System;
|
|
|
using System.Collections.ObjectModel;
|
|
|
using System.ComponentModel;
|
|
|
using System.Linq;
|
|
|
+using System.Reactive.Linq;
|
|
|
using System.Threading;
|
|
|
using System.Threading.Tasks;
|
|
|
using VeloeAvaloniaKemonoPartyApp.Models;
|
|
@@ -22,6 +23,11 @@ namespace VeloeAvaloniaKemonoPartyApp.ViewModels
|
|
|
{
|
|
|
_dialogService = dialogService;
|
|
|
Close = ReactiveCommand.Create(CloseImpl);
|
|
|
+
|
|
|
+ this.WhenAnyValue(x => x.SearchText)
|
|
|
+ .Throttle(TimeSpan.FromMilliseconds(400))
|
|
|
+ .ObserveOn(RxApp.MainThreadScheduler)
|
|
|
+ .Subscribe(InitPosts!);
|
|
|
}
|
|
|
|
|
|
private CancellationTokenSource? _cancellationTokenSource;
|
|
@@ -32,7 +38,14 @@ namespace VeloeAvaloniaKemonoPartyApp.ViewModels
|
|
|
get => _isBusy;
|
|
|
set => this.RaiseAndSetIfChanged(ref _isBusy, value);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ private string _searchText = string.Empty;
|
|
|
+ public string SearchText
|
|
|
+ {
|
|
|
+ get => _searchText;
|
|
|
+ set => this.RaiseAndSetIfChanged(ref _searchText, value);
|
|
|
+ }
|
|
|
+
|
|
|
private Creator _creator;
|
|
|
public Creator Creator
|
|
|
{
|
|
@@ -44,7 +57,7 @@ namespace VeloeAvaloniaKemonoPartyApp.ViewModels
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private async void InitPosts()
|
|
|
+ private async void InitPosts(string search = "")
|
|
|
{
|
|
|
_cancellationTokenSource?.Cancel();
|
|
|
_cancellationTokenSource = new CancellationTokenSource();
|
|
@@ -55,7 +68,7 @@ namespace VeloeAvaloniaKemonoPartyApp.ViewModels
|
|
|
|
|
|
if (_creator is not null)
|
|
|
{
|
|
|
- var posts = await Post.InitPostsAsync(_creator);
|
|
|
+ var posts = await Post.LoadPostsAsync(_creator,0,search);
|
|
|
|
|
|
foreach (var post in posts)
|
|
|
{
|
|
@@ -87,7 +100,7 @@ namespace VeloeAvaloniaKemonoPartyApp.ViewModels
|
|
|
{
|
|
|
var startIndex = Posts.Count;
|
|
|
|
|
|
- var posts = await Post.LoadPostsAsync(_creator,startIndex);
|
|
|
+ var posts = await Post.LoadPostsAsync(_creator,startIndex,SearchText);
|
|
|
|
|
|
foreach (var post in posts)
|
|
|
{
|