Skip to content

Commit 0ccf13e

Browse files
authored
Fix: Fixed NullReferenceException in LaunchPreviewPopupAction (#14211)
1 parent f5e907f commit 0ccf13e

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Files.App/Actions/Content/PreviewPopup/LaunchPreviewPopupAction.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ public async Task ExecuteAsync()
3737
if (provider is null)
3838
return;
3939

40-
await provider.TogglePreviewPopupAsync(context.SelectedItem!.ItemPath);
40+
var itemPath = context.SelectedItem?.ItemPath;
41+
if (itemPath is not null)
42+
await provider.TogglePreviewPopupAsync(itemPath);
4143
}
4244

4345
private async Task SwitchPopupPreviewAsync()
@@ -48,17 +50,19 @@ private async Task SwitchPopupPreviewAsync()
4850
if (provider is null)
4951
return;
5052

51-
await provider.SwitchPreviewAsync(context.SelectedItem!.ItemPath);
53+
var itemPath = context.SelectedItem?.ItemPath;
54+
if (itemPath is not null)
55+
await provider.SwitchPreviewAsync(itemPath);
5256
}
5357
}
5458

55-
public void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
59+
public async void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e)
5660
{
5761
switch (e.PropertyName)
5862
{
5963
case nameof(IContentPageContext.SelectedItems):
6064
OnPropertyChanged(nameof(IsExecutable));
61-
var _ = SwitchPopupPreviewAsync();
65+
await SwitchPopupPreviewAsync();
6266
break;
6367
}
6468
}

0 commit comments

Comments
 (0)