Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fixed issue where options in the conflicts dialog could change when scrolling #14256

Merged
merged 1 commit into from
Dec 18, 2023
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
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