Skip to content

Commit

Permalink
Fix: Fixed issue where options in the conflicts dialog could change w…
Browse files Browse the repository at this point in the history
…hen scrolling (files-community#14256)
  • Loading branch information
hishitetsu authored Dec 18, 2023
1 parent d3f06b0 commit cf569f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/Files.App/Dialogs/FilesystemOperationDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@
</Grid>

<!-- Options -->
<!-- x:Load cannot be used (#14000) -->
<ComboBox
x:Name="ConflictOptions"
Grid.Column="2"
Width="200"
HorizontalAlignment="Right"
VerticalAlignment="Center"
x:Load="{x:Bind IsConflict, Mode=OneWay}"
Loaded="ConflictOptions_Loaded"
SelectedIndex="{x:Bind ConflictResolveOption, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, Converter={StaticResource ConflictResolveOptionToIndexConverter}}">
SelectedIndex="{x:Bind ConflictResolveOption, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, Converter={StaticResource ConflictResolveOptionToIndexConverter}}"
Visibility="{x:Bind IsConflict, Mode=OneWay}">
<ComboBox.Items>
<ComboBoxItem Content="{helpers:ResourceString Name=GenerateNewName}" />
<ComboBoxItem Content="{helpers:ResourceString Name=ReplaceExisting}" />
Expand Down
13 changes: 0 additions & 13 deletions src/Files.App/Dialogs/FilesystemOperationDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,6 @@ private void NameEdit_Loaded(object sender, RoutedEventArgs e)
(sender as TextBox)?.Focus(FocusState.Programmatic);
}

private void ConflictOptions_Loaded(object sender, RoutedEventArgs e)
{
if (sender is ComboBox comboBox)
comboBox.SelectedIndex = ViewModel.LoadConflictResolveOption() switch
{
FileNameConflictResolveOptionType.None => -1,
FileNameConflictResolveOptionType.GenerateNewName => 0,
FileNameConflictResolveOptionType.ReplaceExisting => 1,
FileNameConflictResolveOptionType.Skip => 2,
_ => -1
};
}

private void FilesystemOperationDialog_Opened(ContentDialog sender, ContentDialogOpenedEventArgs args)
{
UpdateDialogLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,18 @@ private FileSystemDialogViewModel(FileSystemDialogMode fileSystemDialogMode, IEn

_dialogClosingCts = new();

_AggregatedResolveOption = _userSettingsService.GeneralSettingsService.ConflictsResolveOption;

_messenger = new WeakReferenceMessenger();
_messenger.Register(this);

foreach (var item in items)
{
if (item is FileSystemDialogConflictItemViewModel conflictItem && conflictItem.IsConflict)
conflictItem.ConflictResolveOption = _AggregatedResolveOption;

item.Messenger = _messenger;
}

Items = new(items);

Expand Down Expand Up @@ -111,11 +118,6 @@ public void Receive(FileSystemDialogOptionChangedMessage message)
}
}

public FileNameConflictResolveOptionType LoadConflictResolveOption()
{
return _userSettingsService.GeneralSettingsService.ConflictsResolveOption;
}

public void SaveConflictResolveOption()
{
if (AggregatedResolveOption != FileNameConflictResolveOptionType.None &&
Expand Down

0 comments on commit cf569f2

Please sign in to comment.