Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ public void when_read_then_search_no_results_key_exists() =>
[Fact]
public void when_read_then_search_result_delete_button_key_exists() =>
RootElement().TryGetProperty("Search.Result.Delete.Button", out _).ShouldBeTrue();

[Fact]
public void when_read_then_search_tags_loading_key_exists() =>
RootElement().TryGetProperty("Search.Tags.Loading", out _).ShouldBeTrue();
}
Original file line number Diff line number Diff line change
Expand Up @@ -502,4 +502,49 @@ public void when_instantiated_then_capped_notice_text_delegates_to_localisation_

sut.CappedNoticeText.ShouldBe("Showing top 500 results. Refine your search to see more.");
}

[Fact]
public void when_instantiated_then_tags_loading_text_delegates_to_localisation_service()
{
loc.GetLocal("Search.Tags.Loading").Returns("Loading categories...");
var sut = CreateSut();

sut.TagsLoadingText.ShouldBe("Loading categories...");
}

[Fact]
public async Task when_view_is_activated_then_is_loading_tags_is_false_after_load()
{
repository.GetDistinctTagNamesAsync(TestAccountId, Arg.Any<CancellationToken>()).Returns([]);
var sut = new SyncedFileSearchViewModel(repository, fileOpenerService, fileTypeClassifier, accountRepository, dispatcher, loc);
sut.SetActiveAccount(TestAccountId);

await sut.OnViewActivatedAsync(CancellationToken.None);

sut.IsLoadingTags.ShouldBeFalse();
}

[Fact]
public async Task when_view_is_activated_with_no_tags_then_show_no_classifications_hint_is_true()
{
repository.GetDistinctTagNamesAsync(TestAccountId, Arg.Any<CancellationToken>()).Returns([]);
var sut = new SyncedFileSearchViewModel(repository, fileOpenerService, fileTypeClassifier, accountRepository, dispatcher, loc);
sut.SetActiveAccount(TestAccountId);

await sut.OnViewActivatedAsync(CancellationToken.None);

sut.ShowNoClassificationsHint.ShouldBeTrue();
}

[Fact]
public async Task when_view_is_activated_with_tags_then_show_no_classifications_hint_is_false()
{
repository.GetDistinctTagNamesAsync(TestAccountId, Arg.Any<CancellationToken>()).Returns(["Image", "Video"]);
var sut = new SyncedFileSearchViewModel(repository, fileOpenerService, fileTypeClassifier, accountRepository, dispatcher, loc);
sut.SetActiveAccount(TestAccountId);

await sut.OnViewActivatedAsync(CancellationToken.None);

sut.ShowNoClassificationsHint.ShouldBeFalse();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
"Search.MinSize.Label": "Min size (bytes)",
"Search.MaxSize.Label": "Max size (bytes)",
"Search.Tags.Label": "Tags",
"Search.Tags.Loading": "Loading categories...",
"Search.Tags.NoClassifications": "No classifications found.",
"Search.DuplicatesOnly.Label": "Duplicates only",
"Search.Button": "Search",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
"Search.MinSize.Label": "US-Min size (bytes)",
"Search.MaxSize.Label": "US-Max size (bytes)",
"Search.Tags.Label": "US-Tags",
"Search.Tags.Loading": "US-Loading categories...",
"Search.Tags.NoClassifications": "US-No classifications found.",
"Search.DuplicatesOnly.Label": "US-Duplicates only",
"Search.Button": "US-Search",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,16 @@
<TextBlock Text="{Binding TagsLabelText}"
FontSize="{StaticResource FontSizeXs}"
Foreground="{DynamicResource TextTertiaryBrush}"/>
<TextBlock Text="{Binding TagsLoadingText}"
FontSize="{StaticResource FontSizeSm}"
Foreground="{DynamicResource TextTertiaryBrush}"
FontStyle="Italic"
IsVisible="{Binding IsLoadingTags}"/>
<TextBlock Text="{Binding TagsNoClassificationsText}"
FontSize="{StaticResource FontSizeSm}"
Foreground="{DynamicResource TextTertiaryBrush}"
FontStyle="Italic"
IsVisible="{Binding AvailableTags.Count, Converter={StaticResource IntZeroToBoolConverter}}"/>
IsVisible="{Binding ShowNoClassificationsHint}"/>
<ScrollViewer MaxHeight="120"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Disabled"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ public sealed partial class SyncedFileSearchViewModel(ISyncedItemRepository repo
[ObservableProperty]
public partial bool IsCapped { get; private set; }

[ObservableProperty]
public partial bool IsLoadingTags { get; private set; }

[ObservableProperty]
public partial bool ShowNoClassificationsHint { get; private set; }

public ObservableCollection<SyncedFileResultViewModel> Results { get; } = [];
public ObservableCollection<string> SelectedTags { get; } = [];
public ObservableCollection<string> AvailableTags { get; } = [];
Expand Down Expand Up @@ -76,6 +82,9 @@ public sealed partial class SyncedFileSearchViewModel(ISyncedItemRepository repo
/// <summary>Localised "Tags" label.</summary>
public string TagsLabelText => loc.GetLocal("Search.Tags.Label");

/// <summary>Localised message shown while categories are being loaded.</summary>
public string TagsLoadingText => loc.GetLocal("Search.Tags.Loading");

/// <summary>Localised message shown when no classifications exist for the active account.</summary>
public string TagsNoClassificationsText => loc.GetLocal("Search.Tags.NoClassifications");

Expand Down Expand Up @@ -125,10 +134,18 @@ public async Task OnViewActivatedAsync(CancellationToken ct)
if (activeAccountId is null)
return;

IsLoadingTags = true;
ShowNoClassificationsHint = false;

var tags = await repository.GetDistinctTagNamesAsync(activeAccountId.Value, ct).ConfigureAwait(false);

if (tags.Count <= cachedTagCount)
{
IsLoadingTags = false;
ShowNoClassificationsHint = AvailableTags.Count == 0;

return;
}

cachedTagCount = tags.Count;

Expand All @@ -137,6 +154,8 @@ public async Task OnViewActivatedAsync(CancellationToken ct)
AvailableTags.Clear();
foreach (string tag in tags)
AvailableTags.Add(tag);
IsLoadingTags = false;
ShowNoClassificationsHint = tags.Count == 0;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"AuthorityForMicrosoftAccountsOnly": "https://login.microsoftonline.com/consumers"
},
"AStarDevOneDriveClient": {
"ApplicationVersion": "0.28.0",
"ApplicationVersion": "0.29.0",
"ApplicationName": "AStar Dev OneDrive Sync Client",
"CacheTag": 1,
"UserPreferencesPath": "astar-dev/astar-dev-onedrive-client",
Expand Down
Loading