Skip to content

Code Quality: Fix async warnings #13832

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

Merged
merged 1 commit into from
Nov 13, 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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override RichGlyph Glyph
public override Task ExecuteAsync()
{
if (context.SelectedItem is not null)
WallpaperHelpers.SetAsBackgroundAsync(WallpaperType.LockScreen, context.SelectedItem.ItemPath);
return WallpaperHelpers.SetAsBackgroundAsync(WallpaperType.LockScreen, context.SelectedItem.ItemPath);

return Task.CompletedTask;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public override RichGlyph Glyph
public override Task ExecuteAsync()
{
if (context.SelectedItem is not null)
WallpaperHelpers.SetAsBackgroundAsync(WallpaperType.Desktop, context.SelectedItem.ItemPath);
return WallpaperHelpers.SetAsBackgroundAsync(WallpaperType.Desktop, context.SelectedItem.ItemPath);

return Task.CompletedTask;
}
Expand Down
18 changes: 9 additions & 9 deletions src/Files.App/ViewModels/UserControls/SidebarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ public async Task UpdateSectionVisibilityAsync(SectionType sectionType, bool sho
}
}

private void UserSettingsService_OnSettingChangedEvent(object sender, SettingChangedEventArgs e)
private async void UserSettingsService_OnSettingChangedEvent(object sender, SettingChangedEventArgs e)
{
switch (e.SettingName)
{
Expand All @@ -608,31 +608,31 @@ private void UserSettingsService_OnSettingChangedEvent(object sender, SettingCha
}
break;
case nameof(UserSettingsService.GeneralSettingsService.ShowFavoritesSection):
UpdateSectionVisibilityAsync(SectionType.Favorites, ShowFavoritesSection);
await UpdateSectionVisibilityAsync(SectionType.Favorites, ShowFavoritesSection);
OnPropertyChanged(nameof(ShowFavoritesSection));
break;
case nameof(UserSettingsService.GeneralSettingsService.ShowLibrarySection):
UpdateSectionVisibilityAsync(SectionType.Library, ShowLibrarySection);
await UpdateSectionVisibilityAsync(SectionType.Library, ShowLibrarySection);
OnPropertyChanged(nameof(ShowLibrarySection));
break;
case nameof(UserSettingsService.GeneralSettingsService.ShowCloudDrivesSection):
UpdateSectionVisibilityAsync(SectionType.CloudDrives, ShowCloudDrivesSection);
await UpdateSectionVisibilityAsync(SectionType.CloudDrives, ShowCloudDrivesSection);
OnPropertyChanged(nameof(ShowCloudDrivesSection));
break;
case nameof(UserSettingsService.GeneralSettingsService.ShowDrivesSection):
UpdateSectionVisibilityAsync(SectionType.Drives, ShowDrivesSection);
await UpdateSectionVisibilityAsync(SectionType.Drives, ShowDrivesSection);
OnPropertyChanged(nameof(ShowDrivesSection));
break;
case nameof(UserSettingsService.GeneralSettingsService.ShowNetworkDrivesSection):
UpdateSectionVisibilityAsync(SectionType.Network, ShowNetworkDrivesSection);
await UpdateSectionVisibilityAsync(SectionType.Network, ShowNetworkDrivesSection);
OnPropertyChanged(nameof(ShowNetworkDrivesSection));
break;
case nameof(UserSettingsService.GeneralSettingsService.ShowWslSection):
UpdateSectionVisibilityAsync(SectionType.WSL, ShowWslSection);
await UpdateSectionVisibilityAsync(SectionType.WSL, ShowWslSection);
OnPropertyChanged(nameof(ShowWslSection));
break;
case nameof(UserSettingsService.GeneralSettingsService.ShowFileTagsSection):
UpdateSectionVisibilityAsync(SectionType.FileTag, ShowFileTagsSection);
await UpdateSectionVisibilityAsync(SectionType.FileTag, ShowFileTagsSection);
OnPropertyChanged(nameof(ShowFileTagsSection));
break;
}
Expand Down Expand Up @@ -1262,7 +1262,7 @@ private async void HandleLocationItemDroppedAsync(LocationItem locationItem, Ite
foreach (var item in storageItems)
{
if (item.ItemType == FilesystemItemType.Directory && !SidebarPinnedModel.FavoriteItems.Contains(item.Path))
QuickAccessService.PinToSidebarAsync(item.Path);
await QuickAccessService.PinToSidebarAsync(item.Path);
}
}
else
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Views/LayoutModes/DetailsLayoutBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,15 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv
protected override bool CanGetItemFromElement(object element)
=> element is ListViewItem;

private void FolderSettings_GridViewSizeChangeRequested(object? sender, EventArgs e)
private async void FolderSettings_GridViewSizeChangeRequested(object? sender, EventArgs e)
{
var requestedIconSize = FolderSettings.GetIconSize(); // Get new icon size

// Prevents reloading icons when the icon size hasn't changed
if (requestedIconSize != currentIconSize)
{
currentIconSize = requestedIconSize; // Update icon size before refreshing
ReloadItemIconsAsync();
await ReloadItemIconsAsync();
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/Files.App/Views/LayoutModes/GridViewBrowser.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected override void OnNavigatingFrom(NavigatingCancelEventArgs e)
FolderSettings.GridViewSizeChangeRequested -= FolderSettings_GridViewSizeChangeRequested;
}

private void FolderSettings_LayoutModeChangeRequested(object? sender, LayoutModeEventArgs e)
private async void FolderSettings_LayoutModeChangeRequested(object? sender, LayoutModeEventArgs e)
{
if (FolderSettings.LayoutMode == FolderLayoutModes.GridView || FolderSettings.LayoutMode == FolderLayoutModes.TilesView)
{
Expand All @@ -121,7 +121,7 @@ private void FolderSettings_LayoutModeChangeRequested(object? sender, LayoutMode
if (requestedIconSize != currentIconSize)
{
currentIconSize = requestedIconSize;
ReloadItemIconsAsync();
await ReloadItemIconsAsync();
}
}
}
Expand Down Expand Up @@ -335,7 +335,7 @@ protected override async void FileList_PreviewKeyDown(object sender, KeyRoutedEv
protected override bool CanGetItemFromElement(object element)
=> element is GridViewItem;

private void FolderSettings_GridViewSizeChangeRequested(object? sender, EventArgs e)
private async void FolderSettings_GridViewSizeChangeRequested(object? sender, EventArgs e)
{
SetItemMinWidth();

Expand All @@ -347,7 +347,7 @@ private void FolderSettings_GridViewSizeChangeRequested(object? sender, EventArg
{
// Update icon size before refreshing
currentIconSize = requestedIconSize;
ReloadItemIconsAsync();
await ReloadItemIconsAsync();
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/Files.App/Views/LayoutModes/StandardLayoutMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ protected override void UnhookEvents()
ItemManipulationModel.RefreshItemsThumbnailInvoked -= ItemManipulationModel_RefreshItemsThumbnail;
}

protected virtual void ItemManipulationModel_RefreshItemsThumbnail(object? sender, EventArgs e)
protected virtual async void ItemManipulationModel_RefreshItemsThumbnail(object? sender, EventArgs e)
{
ReloadSelectedItemsIconAsync();
await ReloadSelectedItemsIconAsync();
}

protected virtual void ItemManipulationModel_RefreshItemThumbnail(object? sender, EventArgs args)
protected virtual async void ItemManipulationModel_RefreshItemThumbnail(object? sender, EventArgs args)
{
ReloadSelectedItemIconAsync();
await ReloadSelectedItemIconAsync();
}

protected virtual async Task ReloadSelectedItemIconAsync()
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Views/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private void SetRectDragRegion()
dragZoneLeftIndent: (int)(TabControl.ActualWidth + TabControl.Margin.Left - TabControl.DragArea.ActualWidth));
}

public void TabItemContent_ContentChanged(object? sender, CustomTabViewItemParameter e)
public async void TabItemContent_ContentChanged(object? sender, CustomTabViewItemParameter e)
{
if (SidebarAdaptiveViewModel.PaneHolder is null)
return;
Expand All @@ -162,7 +162,7 @@ public void TabItemContent_ContentChanged(object? sender, CustomTabViewItemParam
UpdateStatusBarProperties();
LoadPaneChanged();
UpdateNavToolbarProperties();
ViewModel.UpdateInstancePropertiesAsync(paneArgs);
await ViewModel.UpdateInstancePropertiesAsync(paneArgs);
}

public void MultitaskingControl_CurrentInstanceChanged(object? sender, CurrentInstanceChangedEventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions src/Files.App/Views/Settings/AboutPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ public AboutPage()
InitializeComponent();
}

private void ThirdPartyLicenses_Click(object sender, bool e)
private async void ThirdPartyLicenses_Click(object sender, bool e)
{
if (e && ViewModel.ThirdPartyNotices is null)
ViewModel.LoadThirdPartyNoticesAsync();
await ViewModel.LoadThirdPartyNoticesAsync();
}

private async void MarkdownTextBlock_LinkClicked(object sender, LinkClickedEventArgs e)
Expand Down
12 changes: 6 additions & 6 deletions src/Files.App/Views/Shells/BaseShellPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ protected async void ShellPage_TextChanged(ISearchBox sender, SearchBoxTextChang
}
}

protected void ShellPage_RefreshRequested(object sender, EventArgs e)
protected async void ShellPage_RefreshRequested(object sender, EventArgs e)
{
Refresh_Click();
await Refresh_Click();
}

protected void AppSettings_SortDirectionPreferenceUpdated(object sender, SortDirection e)
Expand Down Expand Up @@ -401,9 +401,9 @@ protected async void ShellPage_PathBoxItemDropped(object sender, PathBoxItemDrop
e.SignalEvent?.Set();
}

protected void ShellPage_AddressBarTextEntered(object sender, AddressBarTextEnteredEventArgs e)
protected async void ShellPage_AddressBarTextEntered(object sender, AddressBarTextEnteredEventArgs e)
{
ToolbarViewModel.SetAddressBarSuggestionsAsync(e.AddressBarTextField, this);
await ToolbarViewModel.SetAddressBarSuggestionsAsync(e.AddressBarTextField, this);
}

protected async void ShellPage_ToolbarPathItemLoaded(object sender, ToolbarPathItemLoadedEventArgs e)
Expand All @@ -430,10 +430,10 @@ protected void NavigationToolbar_EditModeEnabled(object sender, EventArgs e)
: FilesystemViewModel.WorkingDirectory;
}

protected void DrivesManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
protected async void DrivesManager_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "ShowUserConsentOnInit")
DisplayFilesystemConsentDialogAsync();
await DisplayFilesystemConsentDialogAsync();
}

// Ensure that the path bar gets updated for user interaction
Expand Down