Skip to content

Commit 208375c

Browse files
committed
Re-enable show/hide sections
1 parent b2c9957 commit 208375c

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

src/Files.Uwp/UserControls/SidebarControl.xaml.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,31 +315,24 @@ private void HideSection()
315315
{
316316
case SectionType.Favorites:
317317
UserSettingsService.AppearanceSettingsService.ShowFavoritesSection = false;
318-
//App.SidebarPinnedController.Model.UpdateFavoritesSectionVisibility();
319318
break;
320319
case SectionType.Library:
321320
UserSettingsService.AppearanceSettingsService.ShowLibrarySection = false;
322-
//App.LibraryManager.UpdateLibrariesSectionVisibility();
323321
break;
324322
case SectionType.CloudDrives:
325323
UserSettingsService.AppearanceSettingsService.ShowCloudDrivesSection = false;
326-
//App.CloudDrivesManager.UpdateCloudDrivesSectionVisibility();
327324
break;
328325
case SectionType.Drives:
329326
UserSettingsService.AppearanceSettingsService.ShowDrivesSection = false;
330-
//App.DrivesManager.UpdateDrivesSectionVisibility();
331327
break;
332328
case SectionType.Network:
333329
UserSettingsService.AppearanceSettingsService.ShowNetworkDrivesSection = false;
334-
//App.NetworkDrivesManager.UpdateNetworkDrivesSectionVisibility();
335330
break;
336331
case SectionType.WSL:
337332
UserSettingsService.AppearanceSettingsService.ShowWslSection = false;
338-
//App.WSLDistroManager.UpdateWslSectionVisibility();
339333
break;
340334
case SectionType.FileTag:
341335
UserSettingsService.AppearanceSettingsService.ShowFileTagsSection = false;
342-
//App.FileTagsManager.UpdateFileTagsSectionVisibility();
343336
break;
344337
}
345338
}

src/Files.Uwp/ViewModels/SettingsViewModels/AppearanceViewModel.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ public bool ShowFavoritesSection
133133
if (value != UserSettingsService.AppearanceSettingsService.ShowFavoritesSection)
134134
{
135135
UserSettingsService.AppearanceSettingsService.ShowFavoritesSection = value;
136-
//App.SidebarPinnedController.Model.UpdateFavoritesSectionVisibility();
137136
OnPropertyChanged();
138137
}
139138
}
@@ -178,7 +177,6 @@ public bool ShowLibrarySection
178177
if (value != UserSettingsService.AppearanceSettingsService.ShowLibrarySection)
179178
{
180179
UserSettingsService.AppearanceSettingsService.ShowLibrarySection = value;
181-
//App.LibraryManager.UpdateLibrariesSectionVisibility();
182180
OnPropertyChanged();
183181
}
184182
}
@@ -192,7 +190,6 @@ public bool ShowDrivesSection
192190
if (value != UserSettingsService.AppearanceSettingsService.ShowDrivesSection)
193191
{
194192
UserSettingsService.AppearanceSettingsService.ShowDrivesSection = value;
195-
//App.DrivesManager.UpdateDrivesSectionVisibility();
196193
OnPropertyChanged();
197194
}
198195
}
@@ -206,7 +203,6 @@ public bool ShowCloudDrivesSection
206203
if (value != UserSettingsService.AppearanceSettingsService.ShowCloudDrivesSection)
207204
{
208205
UserSettingsService.AppearanceSettingsService.ShowCloudDrivesSection = value;
209-
//App.CloudDrivesManager.UpdateCloudDrivesSectionVisibility();
210206
OnPropertyChanged();
211207
}
212208
}
@@ -220,7 +216,6 @@ public bool ShowNetworkDrivesSection
220216
if (value != UserSettingsService.AppearanceSettingsService.ShowNetworkDrivesSection)
221217
{
222218
UserSettingsService.AppearanceSettingsService.ShowNetworkDrivesSection = value;
223-
//App.NetworkDrivesManager.UpdateNetworkDrivesSectionVisibility();
224219
OnPropertyChanged();
225220
}
226221
}
@@ -234,7 +229,6 @@ public bool ShowWslSection
234229
if (value != UserSettingsService.AppearanceSettingsService.ShowWslSection)
235230
{
236231
UserSettingsService.AppearanceSettingsService.ShowWslSection = value;
237-
//App.WSLDistroManager.UpdateWslSectionVisibility();
238232
OnPropertyChanged();
239233
}
240234
}
@@ -250,7 +244,6 @@ public bool ShowFileTagsSection
250244
if (value != UserSettingsService.AppearanceSettingsService.ShowFileTagsSection)
251245
{
252246
UserSettingsService.AppearanceSettingsService.ShowFileTagsSection = value;
253-
//App.FileTagsManager.UpdateFileTagsSectionVisibility();
254247
OnPropertyChanged();
255248
}
256249
}

src/Files.Uwp/ViewModels/SidebarViewModel.cs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public bool ShowFavoritesSection
131131
if (value != UserSettingsService.AppearanceSettingsService.ShowFavoritesSection)
132132
{
133133
UserSettingsService.AppearanceSettingsService.ShowFavoritesSection = value;
134-
//App.SidebarPinnedController.Model.UpdateFavoritesSectionVisibility();
134+
UpdateSectionVisibility(SectionType.Favorites, value);
135135
}
136136
}
137137
}
@@ -144,7 +144,7 @@ public bool ShowLibrarySection
144144
if (value != UserSettingsService.AppearanceSettingsService.ShowLibrarySection)
145145
{
146146
UserSettingsService.AppearanceSettingsService.ShowLibrarySection = value;
147-
//App.LibraryManager.UpdateLibrariesSectionVisibility();
147+
UpdateSectionVisibility(SectionType.Library, value);
148148
}
149149
}
150150
}
@@ -157,7 +157,7 @@ public bool ShowDrivesSection
157157
if (value != UserSettingsService.AppearanceSettingsService.ShowDrivesSection)
158158
{
159159
UserSettingsService.AppearanceSettingsService.ShowDrivesSection = value;
160-
//App.DrivesManager.UpdateDrivesSectionVisibility();
160+
UpdateSectionVisibility(SectionType.Drives, value);
161161
}
162162
}
163163
}
@@ -170,7 +170,7 @@ public bool ShowCloudDrivesSection
170170
if (value != UserSettingsService.AppearanceSettingsService.ShowCloudDrivesSection)
171171
{
172172
UserSettingsService.AppearanceSettingsService.ShowCloudDrivesSection = value;
173-
//App.CloudDrivesManager.UpdateCloudDrivesSectionVisibility();
173+
UpdateSectionVisibility(SectionType.CloudDrives, value);
174174
}
175175
}
176176
}
@@ -183,7 +183,7 @@ public bool ShowNetworkDrivesSection
183183
if (value != UserSettingsService.AppearanceSettingsService.ShowNetworkDrivesSection)
184184
{
185185
UserSettingsService.AppearanceSettingsService.ShowNetworkDrivesSection = value;
186-
//App.NetworkDrivesManager.UpdateNetworkDrivesSectionVisibility();
186+
UpdateSectionVisibility(SectionType.Network, value);
187187
}
188188
}
189189
}
@@ -196,7 +196,7 @@ public bool ShowWslSection
196196
if (value != UserSettingsService.AppearanceSettingsService.ShowWslSection)
197197
{
198198
UserSettingsService.AppearanceSettingsService.ShowWslSection = value;
199-
//App.WSLDistroManager.UpdateWslSectionVisibility();
199+
UpdateSectionVisibility(SectionType.WSL, value);
200200
}
201201
}
202202
}
@@ -209,7 +209,7 @@ public bool ShowFileTagsSection
209209
if (value != UserSettingsService.AppearanceSettingsService.ShowFileTagsSection)
210210
{
211211
UserSettingsService.AppearanceSettingsService.ShowFileTagsSection = value;
212-
//App.FileTagsManager.UpdateFileTagsSectionVisibility();
212+
UpdateSectionVisibility(SectionType.FileTag, value);
213213
}
214214
}
215215
}
@@ -542,6 +542,29 @@ private async Task<LocationItem> GetOrCreateSection(SectionType sectionType)
542542
}
543543
}
544544

545+
public async void UpdateSectionVisibility(SectionType sectionType, bool show)
546+
{
547+
if (show)
548+
{
549+
Func<Task> action = sectionType switch
550+
{
551+
SectionType.CloudDrives => App.CloudDrivesManager.EnumerateDrivesAsync,
552+
SectionType.Drives => App.DrivesManager.EnumerateDrivesAsync,
553+
SectionType.Network => App.NetworkDrivesManager.EnumerateDrivesAsync,
554+
SectionType.WSL => App.WSLDistroManager.EnumerateDrivesAsync,
555+
SectionType.FileTag => App.FileTagsManager.EnumerateFileTagsAsync,
556+
SectionType.Library => App.LibraryManager.EnumerateLibrariesAsync,
557+
SectionType.Favorites => App.SidebarPinnedController.Model.AddAllItemsToSidebar,
558+
_ => () => Task.CompletedTask
559+
};
560+
await action();
561+
}
562+
else
563+
{
564+
SideBarItems.Remove(SideBarItems.FirstOrDefault(x => x.Section == sectionType));
565+
}
566+
}
567+
545568
public async void EmptyRecycleBin(RoutedEventArgs e)
546569
{
547570
await RecycleBinHelpers.S_EmptyRecycleBin();

0 commit comments

Comments
 (0)