Repository: files-community/Files
File: src/Files.App/Helpers/Layout/LayoutPreferencesManager.cs (C#)

Code before:
			if (preferencesItem is null)
				return typeof(DetailsLayoutPage);

			if (changeLayoutMode)
			{
				IsLayoutModeChanging = LayoutPreferencesItem.LayoutMode != preferencesItem.LayoutMode;
				LayoutPreferencesItem = preferencesItem;
			}

			return (preferencesItem.LayoutMode) switch
			{
				FolderLayoutModes.DetailsView => typeof(DetailsLayoutPage),
				FolderLayoutModes.ListView => typeof(GridLayoutPage),
				FolderLayoutModes.TilesView => typeof(GridLayoutPage),
				FolderLayoutModes.GridView => typeof(GridLayoutPage),
				FolderLayoutModes.ColumnView => typeof(ColumnsLayoutPage),
				_ => typeof(DetailsLayoutPage)
			};
		}

		public void UpdateGroupAndSortOptions(string? path)
		{
			if (string.IsNullOrWhiteSpace(path))
				return;

			var preferencesItem = GetLayoutPreferencesForPath(path);
			if (preferencesItem is null)
				return;

			DirectorySortOption = preferencesItem.DirectorySortOption;
			DirectorySortDirection = preferencesItem.DirectorySortDirection;
			DirectoryGroupOption = preferencesItem.DirectoryGroupOption;
			DirectoryGroupByDateUnit = preferencesItem.DirectoryGroupByDateUnit;
			DirectoryGroupDirection = preferencesItem.DirectoryGroupDirection;
			SortDirectoriesAlongsideFiles = preferencesItem.SortDirectoriesAlongsideFiles;
			SortFilesFirst = preferencesItem.SortFilesFirst;
		}

		public bool IsPathUsingDefaultLayout(string? path)
		{
			return UserSettingsService.LayoutSettingsService.SyncFolderPreferencesAcrossDirectories ||
				string.IsNullOrEmpty(path) ||
				GetLayoutPreferencesFromDatabase(path, Win32Helper.GetFolderFRN(path)) is null;
		}

		public void ToggleLayoutModeColumnView(bool manuallySet)
		{
			IsAdaptiveLayoutEnabled &= !manuallySet;

			// Column View
			LayoutMode = FolderLayoutModes.ColumnView;

Review comment (refactor):
Do we need to reload the preferences, or can we simplify this further by just invoking the related events (eg `GroupDirectionPreferenceUpdated`)?

Code after:
			if (preferencesItem is null)
				return typeof(DetailsLayoutPage);

			if (changeLayoutMode)
			{
				IsLayoutModeChanging = LayoutPreferencesItem.LayoutMode != preferencesItem.LayoutMode;
				LayoutPreferencesItem = preferencesItem;
			}

			return (preferencesItem.LayoutMode) switch
			{
				FolderLayoutModes.DetailsView => typeof(DetailsLayoutPage),
				FolderLayoutModes.ListView => typeof(GridLayoutPage),
				FolderLayoutModes.TilesView => typeof(GridLayoutPage),
				FolderLayoutModes.GridView => typeof(GridLayoutPage),
				FolderLayoutModes.ColumnView => typeof(ColumnsLayoutPage),
				_ => typeof(DetailsLayoutPage)
			};
		}

		public void ReloadGroupAndSortPreferences(string? path)
		{
			if (string.IsNullOrWhiteSpace(path))
				return;

			var preferencesItem = GetLayoutPreferencesForPath(path);
			if (preferencesItem is null)
				return;

			DirectorySortOption = preferencesItem.DirectorySortOption;
			DirectorySortDirection = preferencesItem.DirectorySortDirection;
			DirectoryGroupOption = preferencesItem.DirectoryGroupOption;
			DirectoryGroupByDateUnit = preferencesItem.DirectoryGroupByDateUnit;
			DirectoryGroupDirection = preferencesItem.DirectoryGroupDirection;
			SortDirectoriesAlongsideFiles = preferencesItem.SortDirectoriesAlongsideFiles;
			SortFilesFirst = preferencesItem.SortFilesFirst;
		}

		public bool IsPathUsingDefaultLayout(string? path)
		{
			return UserSettingsService.LayoutSettingsService.SyncFolderPreferencesAcrossDirectories ||
				string.IsNullOrEmpty(path) ||
				GetLayoutPreferencesFromDatabase(path, Win32Helper.GetFolderFRN(path)) is null;
		}

		public void ToggleLayoutModeColumnView(bool manuallySet)
		{
			IsAdaptiveLayoutEnabled &= !manuallySet;

			// Column View
			LayoutMode = FolderLayoutModes.ColumnView;