Skip to content

Commit

Permalink
Fixed non-distinct palettes in browser
Browse files Browse the repository at this point in the history
Fix from 5ad10a4 in avalonia branch
  • Loading branch information
CPKreu committed May 20, 2024
1 parent 7a10c4e commit 3791380
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/PixiEditor/Models/DataProviders/LocalPalettesFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using PixiEditor.Extensions.Common.UserPreferences;
using PixiEditor.Extensions.Palettes;
using PixiEditor.Extensions.Palettes.Parsers;
using PixiEditor.Helpers;
using PixiEditor.Models.DataHolders;
using PixiEditor.Models.DataHolders.Palettes;
using PixiEditor.Models.IO;
Expand Down Expand Up @@ -150,7 +151,7 @@ public async Task RefreshCacheAll()
{
string[] files = DirectoryExtensions.GetFiles(
Paths.PathToPalettesFolder,
string.Join("|", AvailableParsers.SelectMany(x => x.SupportedFileExtensions)),
string.Join("|", AvailableParsers.SelectMany(x => x.SupportedFileExtensions).Distinct()),
SearchOption.TopDirectoryOnly);
cachedPalettes = await ParseAll(files);
CacheUpdated?.Invoke(RefreshType.All, null, null);
Expand Down
4 changes: 2 additions & 2 deletions src/PixiEditor/Views/Dialogs/PalettesBrowser.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
<DockPanel Background="{StaticResource MainColor}" Grid.Row="1">
<StackPanel HorizontalAlignment="Left" Margin="10" Orientation="Horizontal" VerticalAlignment="Center">
<Label ui:Translator.Key="SORT_BY" Style="{StaticResource BaseLabel}" VerticalAlignment="Center"/>
<ComboBox x:Name="sortingComboBox" VerticalAlignment="Center" SelectionChanged="SortingComboBox_SelectionChanged">
<ComboBoxItem IsSelected="True" ui:Translator.Key="DEFAULT"/>
<ComboBox x:Name="sortingComboBox" SelectedIndex="0" VerticalAlignment="Center" SelectionChanged="SortingComboBox_SelectionChanged">
<ComboBoxItem ui:Translator.Key="DEFAULT"/>
<ComboBoxItem ui:Translator.Key="ALPHABETICAL"/>
<ComboBoxItem ui:Translator.Key="COLOR_COUNT"/>
</ComboBox>
Expand Down
12 changes: 10 additions & 2 deletions src/PixiEditor/Views/Dialogs/PalettesBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,16 @@ private void HandleCacheItemUpdated(Palette updatedItem)

private void HandleCachePaletteCreated(Palette updatedItem)
{
SortedResults.Add(updatedItem);
PaletteList.Palettes.Add(updatedItem);
if (!SortedResults.Contains(updatedItem))
{
SortedResults.Add(updatedItem);
}

if(!PaletteList.Palettes.Contains(updatedItem))
{
PaletteList.Palettes.Add(updatedItem);
}

Sort();
}

Expand Down

0 comments on commit 3791380

Please sign in to comment.