|
|
@ -1,13 +1,10 @@ |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.ObjectModel; |
|
|
|
using System.Collections.ObjectModel; |
|
|
|
using System.ComponentModel; |
|
|
|
|
|
|
|
using System.Diagnostics; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq; |
|
|
|
using System.Net.Http; |
|
|
|
using System.Net.Http; |
|
|
|
using System.Reactive; |
|
|
|
|
|
|
|
using System.Reactive.Linq; |
|
|
|
using System.Reactive.Linq; |
|
|
|
using System.Threading; |
|
|
|
|
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using AsyncAwaitBestPractices; |
|
|
|
using AsyncAwaitBestPractices; |
|
|
|
using Avalonia.Collections; |
|
|
|
using Avalonia.Collections; |
|
|
@ -15,12 +12,15 @@ using Avalonia.Controls; |
|
|
|
using Avalonia.Controls.Notifications; |
|
|
|
using Avalonia.Controls.Notifications; |
|
|
|
using CommunityToolkit.Mvvm.ComponentModel; |
|
|
|
using CommunityToolkit.Mvvm.ComponentModel; |
|
|
|
using CommunityToolkit.Mvvm.Input; |
|
|
|
using CommunityToolkit.Mvvm.Input; |
|
|
|
|
|
|
|
using DynamicData; |
|
|
|
|
|
|
|
using DynamicData.Alias; |
|
|
|
|
|
|
|
using DynamicData.Binding; |
|
|
|
using LiteDB; |
|
|
|
using LiteDB; |
|
|
|
using LiteDB.Async; |
|
|
|
using LiteDB.Async; |
|
|
|
using NLog; |
|
|
|
using NLog; |
|
|
|
using OneOf.Types; |
|
|
|
|
|
|
|
using Refit; |
|
|
|
using Refit; |
|
|
|
using StabilityMatrix.Avalonia.Languages; |
|
|
|
using StabilityMatrix.Avalonia.Languages; |
|
|
|
|
|
|
|
using StabilityMatrix.Avalonia.Models; |
|
|
|
using StabilityMatrix.Avalonia.Services; |
|
|
|
using StabilityMatrix.Avalonia.Services; |
|
|
|
using StabilityMatrix.Avalonia.ViewModels.Base; |
|
|
|
using StabilityMatrix.Avalonia.ViewModels.Base; |
|
|
|
using StabilityMatrix.Avalonia.ViewModels.CheckpointManager; |
|
|
|
using StabilityMatrix.Avalonia.ViewModels.CheckpointManager; |
|
|
@ -41,24 +41,24 @@ namespace StabilityMatrix.Avalonia.ViewModels.CheckpointBrowser; |
|
|
|
|
|
|
|
|
|
|
|
[View(typeof(CivitAiBrowserPage))] |
|
|
|
[View(typeof(CivitAiBrowserPage))] |
|
|
|
[Singleton] |
|
|
|
[Singleton] |
|
|
|
public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
public partial class CivitAiBrowserViewModel : TabViewModelBase, IInfinitelyScroll |
|
|
|
{ |
|
|
|
{ |
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); |
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); |
|
|
|
private readonly ICivitApi civitApi; |
|
|
|
private readonly ICivitApi civitApi; |
|
|
|
private readonly IDownloadService downloadService; |
|
|
|
|
|
|
|
private readonly ISettingsManager settingsManager; |
|
|
|
private readonly ISettingsManager settingsManager; |
|
|
|
private readonly ServiceManager<ViewModelBase> dialogFactory; |
|
|
|
private readonly ServiceManager<ViewModelBase> dialogFactory; |
|
|
|
private readonly ILiteDbContext liteDbContext; |
|
|
|
private readonly ILiteDbContext liteDbContext; |
|
|
|
private readonly INotificationService notificationService; |
|
|
|
private readonly INotificationService notificationService; |
|
|
|
private const int MaxModelsPerPage = 20; |
|
|
|
private const int MaxModelsPerPage = 20; |
|
|
|
|
|
|
|
|
|
|
|
private LRUCache< |
|
|
|
private LRUCache< |
|
|
|
int /* model id */ |
|
|
|
int /* model id */ |
|
|
|
, |
|
|
|
, |
|
|
|
CheckpointBrowserCardViewModel |
|
|
|
CheckpointBrowserCardViewModel |
|
|
|
> cache = new(50); |
|
|
|
> cache = new(150); |
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty] |
|
|
|
[ObservableProperty] |
|
|
|
private ObservableCollection<CheckpointBrowserCardViewModel>? modelCards; |
|
|
|
private ObservableCollection<CheckpointBrowserCardViewModel> modelCards = new(); |
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty] |
|
|
|
[ObservableProperty] |
|
|
|
private DataGridCollectionView? modelCardsView; |
|
|
|
private DataGridCollectionView? modelCardsView; |
|
|
@ -81,27 +81,9 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
[ObservableProperty] |
|
|
|
[ObservableProperty] |
|
|
|
private CivitModelType selectedModelType = CivitModelType.Checkpoint; |
|
|
|
private CivitModelType selectedModelType = CivitModelType.Checkpoint; |
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty] |
|
|
|
|
|
|
|
private int currentPageNumber; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty] |
|
|
|
|
|
|
|
private int totalPages; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty] |
|
|
|
[ObservableProperty] |
|
|
|
private bool hasSearched; |
|
|
|
private bool hasSearched; |
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty] |
|
|
|
|
|
|
|
private bool canGoToNextPage; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty] |
|
|
|
|
|
|
|
private bool canGoToPreviousPage; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty] |
|
|
|
|
|
|
|
private bool canGoToFirstPage; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty] |
|
|
|
|
|
|
|
private bool canGoToLastPage; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty] |
|
|
|
[ObservableProperty] |
|
|
|
private bool isIndeterminate; |
|
|
|
private bool isIndeterminate; |
|
|
|
|
|
|
|
|
|
|
@ -117,7 +99,8 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
[ObservableProperty] |
|
|
|
[ObservableProperty] |
|
|
|
private bool showSantaHats = true; |
|
|
|
private bool showSantaHats = true; |
|
|
|
|
|
|
|
|
|
|
|
private List<CheckpointBrowserCardViewModel> allModelCards = new(); |
|
|
|
[ObservableProperty] |
|
|
|
|
|
|
|
private string? nextPageCursor; |
|
|
|
|
|
|
|
|
|
|
|
public IEnumerable<CivitPeriod> AllCivitPeriods => |
|
|
|
public IEnumerable<CivitPeriod> AllCivitPeriods => |
|
|
|
Enum.GetValues(typeof(CivitPeriod)).Cast<CivitPeriod>(); |
|
|
|
Enum.GetValues(typeof(CivitPeriod)).Cast<CivitPeriod>(); |
|
|
@ -143,25 +126,11 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
) |
|
|
|
) |
|
|
|
{ |
|
|
|
{ |
|
|
|
this.civitApi = civitApi; |
|
|
|
this.civitApi = civitApi; |
|
|
|
this.downloadService = downloadService; |
|
|
|
|
|
|
|
this.settingsManager = settingsManager; |
|
|
|
this.settingsManager = settingsManager; |
|
|
|
this.dialogFactory = dialogFactory; |
|
|
|
this.dialogFactory = dialogFactory; |
|
|
|
this.liteDbContext = liteDbContext; |
|
|
|
this.liteDbContext = liteDbContext; |
|
|
|
this.notificationService = notificationService; |
|
|
|
this.notificationService = notificationService; |
|
|
|
|
|
|
|
|
|
|
|
CurrentPageNumber = 1; |
|
|
|
|
|
|
|
CanGoToNextPage = true; |
|
|
|
|
|
|
|
CanGoToLastPage = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Observable |
|
|
|
|
|
|
|
.FromEventPattern<PropertyChangedEventArgs>(this, nameof(PropertyChanged)) |
|
|
|
|
|
|
|
.Where(x => x.EventArgs.PropertyName == nameof(CurrentPageNumber)) |
|
|
|
|
|
|
|
.Throttle(TimeSpan.FromMilliseconds(250)) |
|
|
|
|
|
|
|
.Select<EventPattern<PropertyChangedEventArgs>, int>(_ => CurrentPageNumber) |
|
|
|
|
|
|
|
.Where(page => page <= TotalPages && page > 0) |
|
|
|
|
|
|
|
.ObserveOn(SynchronizationContext.Current) |
|
|
|
|
|
|
|
.Subscribe(_ => TrySearchAgain(false).SafeFireAndForget(), err => Logger.Error(err)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EventManager.Instance.NavigateAndFindCivitModelRequested += OnNavigateAndFindCivitModelRequested; |
|
|
|
EventManager.Instance.NavigateAndFindCivitModelRequested += OnNavigateAndFindCivitModelRequested; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -171,7 +140,7 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
SearchQuery = $"$#{e}"; |
|
|
|
SearchQuery = $"$#{e}"; |
|
|
|
SearchModelsCommand.ExecuteAsync(null).SafeFireAndForget(); |
|
|
|
SearchModelsCommand.ExecuteAsync(false).SafeFireAndForget(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override void OnLoaded() |
|
|
|
public override void OnLoaded() |
|
|
@ -223,7 +192,7 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// Background update task |
|
|
|
/// Background update task |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
private async Task CivitModelQuery(CivitModelsRequest request) |
|
|
|
private async Task CivitModelQuery(CivitModelsRequest request, bool isInfiniteScroll = false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var timer = Stopwatch.StartNew(); |
|
|
|
var timer = Stopwatch.StartNew(); |
|
|
|
var queryText = request.Query; |
|
|
|
var queryText = request.Query; |
|
|
@ -276,15 +245,9 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
} |
|
|
|
} |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (cacheNew) |
|
|
|
UpdateModelCards(models, isInfiniteScroll); |
|
|
|
{ |
|
|
|
|
|
|
|
Logger.Debug("New cache entry, updating model cards"); |
|
|
|
NextPageCursor = modelsResponse.Metadata?.NextCursor; |
|
|
|
UpdateModelCards(models, modelsResponse.Metadata); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Logger.Debug("Cache entry already exists, not updating model cards"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
catch (OperationCanceledException) |
|
|
|
catch (OperationCanceledException) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -327,7 +290,7 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
|
/// Updates model cards using api response object. |
|
|
|
/// Updates model cards using api response object. |
|
|
|
/// </summary> |
|
|
|
/// </summary> |
|
|
|
private void UpdateModelCards(IEnumerable<CivitModel>? models, CivitMetadata? metadata) |
|
|
|
private void UpdateModelCards(List<CivitModel>? models, bool addCards = false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (models is null) |
|
|
|
if (models is null) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -335,7 +298,7 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
var updateCards = models |
|
|
|
var modelsToAdd = models |
|
|
|
.Select(model => |
|
|
|
.Select(model => |
|
|
|
{ |
|
|
|
{ |
|
|
|
var cachedViewModel = cache.Get(model.Id); |
|
|
|
var cachedViewModel = cache.Get(model.Id); |
|
|
@ -364,23 +327,34 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
|
|
|
|
|
|
|
|
return newCard; |
|
|
|
return newCard; |
|
|
|
}) |
|
|
|
}) |
|
|
|
.ToList(); |
|
|
|
.Where(FilterModelCardsPredicate); |
|
|
|
|
|
|
|
|
|
|
|
allModelCards = updateCards; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var filteredCards = updateCards.Where(FilterModelCardsPredicate); |
|
|
|
|
|
|
|
if (SortMode == CivitSortMode.Installed) |
|
|
|
if (SortMode == CivitSortMode.Installed) |
|
|
|
{ |
|
|
|
{ |
|
|
|
filteredCards = filteredCards.OrderByDescending(x => x.UpdateCardText == "Update Available"); |
|
|
|
modelsToAdd = modelsToAdd.OrderByDescending(x => x.UpdateCardText == "Update Available"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ModelCards = new ObservableCollection<CheckpointBrowserCardViewModel>(filteredCards); |
|
|
|
if (!addCards) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ModelCards = new ObservableCollection<CheckpointBrowserCardViewModel>(modelsToAdd); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
foreach (var model in modelsToAdd) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if ( |
|
|
|
|
|
|
|
ModelCards.Contains( |
|
|
|
|
|
|
|
model, |
|
|
|
|
|
|
|
new PropertyComparer<CheckpointBrowserCardViewModel>(x => x.CivitModel.Id) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ModelCards.Add(model); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
TotalPages = metadata?.TotalPages ?? 1; |
|
|
|
|
|
|
|
CanGoToFirstPage = CurrentPageNumber != 1; |
|
|
|
|
|
|
|
CanGoToPreviousPage = CurrentPageNumber > 1; |
|
|
|
|
|
|
|
CanGoToNextPage = CurrentPageNumber < TotalPages; |
|
|
|
|
|
|
|
CanGoToLastPage = CurrentPageNumber != TotalPages; |
|
|
|
|
|
|
|
// Status update |
|
|
|
// Status update |
|
|
|
ShowMainLoadingSpinner = false; |
|
|
|
ShowMainLoadingSpinner = false; |
|
|
|
IsIndeterminate = false; |
|
|
|
IsIndeterminate = false; |
|
|
@ -390,27 +364,30 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
private string previousSearchQuery = string.Empty; |
|
|
|
private string previousSearchQuery = string.Empty; |
|
|
|
|
|
|
|
|
|
|
|
[RelayCommand] |
|
|
|
[RelayCommand] |
|
|
|
private async Task SearchModels() |
|
|
|
private async Task SearchModels(bool isInfiniteScroll = false) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var timer = Stopwatch.StartNew(); |
|
|
|
var timer = Stopwatch.StartNew(); |
|
|
|
|
|
|
|
|
|
|
|
if (SearchQuery != previousSearchQuery) |
|
|
|
if (SearchQuery != previousSearchQuery || !isInfiniteScroll) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Reset page number |
|
|
|
// Reset page number |
|
|
|
CurrentPageNumber = 1; |
|
|
|
|
|
|
|
previousSearchQuery = SearchQuery; |
|
|
|
previousSearchQuery = SearchQuery; |
|
|
|
|
|
|
|
NextPageCursor = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Build request |
|
|
|
// Build request |
|
|
|
var modelRequest = new CivitModelsRequest |
|
|
|
var modelRequest = new CivitModelsRequest |
|
|
|
{ |
|
|
|
{ |
|
|
|
Limit = MaxModelsPerPage, |
|
|
|
|
|
|
|
Nsfw = "true", // Handled by local view filter |
|
|
|
Nsfw = "true", // Handled by local view filter |
|
|
|
Sort = SortMode, |
|
|
|
Sort = SortMode, |
|
|
|
Period = SelectedPeriod, |
|
|
|
Period = SelectedPeriod |
|
|
|
Page = CurrentPageNumber |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (NextPageCursor != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
modelRequest.Cursor = NextPageCursor; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (SelectedModelType != CivitModelType.All) |
|
|
|
if (SelectedModelType != CivitModelType.All) |
|
|
|
{ |
|
|
|
{ |
|
|
|
modelRequest.Types = [SelectedModelType]; |
|
|
|
modelRequest.Types = [SelectedModelType]; |
|
|
@ -516,14 +493,15 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
modelRequest.GetHashCode(), |
|
|
|
modelRequest.GetHashCode(), |
|
|
|
elapsed.TotalSeconds |
|
|
|
elapsed.TotalSeconds |
|
|
|
); |
|
|
|
); |
|
|
|
UpdateModelCards(cachedQuery.Items, cachedQuery.Metadata); |
|
|
|
NextPageCursor = cachedQuery.Metadata?.NextCursor; |
|
|
|
|
|
|
|
UpdateModelCards(cachedQuery.Items, isInfiniteScroll); |
|
|
|
|
|
|
|
|
|
|
|
// Start remote query (background mode) |
|
|
|
// Start remote query (background mode) |
|
|
|
// Skip when last query was less than 2 min ago |
|
|
|
// Skip when last query was less than 2 min ago |
|
|
|
var timeSinceCache = DateTimeOffset.UtcNow - cachedQuery.InsertedAt; |
|
|
|
var timeSinceCache = DateTimeOffset.UtcNow - cachedQuery.InsertedAt; |
|
|
|
if (timeSinceCache?.TotalMinutes >= 2) |
|
|
|
if (timeSinceCache?.TotalMinutes >= 2) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CivitModelQuery(modelRequest).SafeFireAndForget(); |
|
|
|
CivitModelQuery(modelRequest, isInfiniteScroll).SafeFireAndForget(); |
|
|
|
Logger.Debug( |
|
|
|
Logger.Debug( |
|
|
|
"Cached query was more than 2 minutes ago ({Seconds:F0} s), updating cache with remote query", |
|
|
|
"Cached query was more than 2 minutes ago ({Seconds:F0} s), updating cache with remote query", |
|
|
|
timeSinceCache.Value.TotalSeconds |
|
|
|
timeSinceCache.Value.TotalSeconds |
|
|
@ -534,54 +512,23 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Not cached, wait for remote query |
|
|
|
// Not cached, wait for remote query |
|
|
|
ShowMainLoadingSpinner = true; |
|
|
|
ShowMainLoadingSpinner = true; |
|
|
|
await CivitModelQuery(modelRequest); |
|
|
|
await CivitModelQuery(modelRequest, isInfiniteScroll); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
UpdateResultsText(); |
|
|
|
UpdateResultsText(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void FirstPage() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CurrentPageNumber = 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void PreviousPage() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (CurrentPageNumber == 1) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CurrentPageNumber--; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void NextPage() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (CurrentPageNumber == TotalPages) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CurrentPageNumber++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void LastPage() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
CurrentPageNumber = TotalPages; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void ClearSearchQuery() |
|
|
|
public void ClearSearchQuery() |
|
|
|
{ |
|
|
|
{ |
|
|
|
SearchQuery = string.Empty; |
|
|
|
SearchQuery = string.Empty; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
partial void OnShowNsfwChanged(bool value) |
|
|
|
public async Task LoadNextPageAsync() |
|
|
|
{ |
|
|
|
{ |
|
|
|
settingsManager.Transaction(s => s.ModelBrowserNsfwEnabled, value); |
|
|
|
if (NextPageCursor != null) |
|
|
|
// ModelCardsView?.Refresh(); |
|
|
|
{ |
|
|
|
var updateCards = allModelCards.Where(FilterModelCardsPredicate); |
|
|
|
await SearchModelsCommand.ExecuteAsync(true); |
|
|
|
ModelCards = new ObservableCollection<CheckpointBrowserCardViewModel>(updateCards); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!HasSearched) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UpdateResultsText(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
partial void OnSelectedPeriodChanged(CivitPeriod value) |
|
|
|
partial void OnSelectedPeriodChanged(CivitPeriod value) |
|
|
@ -596,6 +543,7 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
SelectedBaseModelType |
|
|
|
SelectedBaseModelType |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
NextPageCursor = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
partial void OnSortModeChanged(CivitSortMode value) |
|
|
|
partial void OnSortModeChanged(CivitSortMode value) |
|
|
@ -610,6 +558,7 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
SelectedBaseModelType |
|
|
|
SelectedBaseModelType |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
NextPageCursor = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
partial void OnSelectedModelTypeChanged(CivitModelType value) |
|
|
|
partial void OnSelectedModelTypeChanged(CivitModelType value) |
|
|
@ -624,6 +573,7 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
SelectedBaseModelType |
|
|
|
SelectedBaseModelType |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
NextPageCursor = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
partial void OnSelectedBaseModelTypeChanged(string value) |
|
|
|
partial void OnSelectedBaseModelTypeChanged(string value) |
|
|
@ -638,6 +588,7 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
value |
|
|
|
value |
|
|
|
) |
|
|
|
) |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
NextPageCursor = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async Task TrySearchAgain(bool shouldUpdatePageNumber = true) |
|
|
|
private async Task TrySearchAgain(bool shouldUpdatePageNumber = true) |
|
|
@ -648,18 +599,17 @@ public partial class CivitAiBrowserViewModel : TabViewModelBase |
|
|
|
|
|
|
|
|
|
|
|
if (shouldUpdatePageNumber) |
|
|
|
if (shouldUpdatePageNumber) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CurrentPageNumber = 1; |
|
|
|
NextPageCursor = null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// execute command instead of calling method directly so that the IsRunning property gets updated |
|
|
|
// execute command instead of calling method directly so that the IsRunning property gets updated |
|
|
|
await SearchModelsCommand.ExecuteAsync(null); |
|
|
|
await SearchModelsCommand.ExecuteAsync(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void UpdateResultsText() |
|
|
|
private void UpdateResultsText() |
|
|
|
{ |
|
|
|
{ |
|
|
|
NoResultsFound = ModelCards?.Count <= 0; |
|
|
|
NoResultsFound = ModelCards?.Count <= 0; |
|
|
|
NoResultsText = |
|
|
|
NoResultsText = "No results found"; |
|
|
|
allModelCards.Count > 0 ? $"{allModelCards.Count} results hidden by filters" : "No results found"; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override string Header => Resources.Label_CivitAi; |
|
|
|
public override string Header => Resources.Label_CivitAi; |
|
|
|