Skip to content

Commit 65e511d

Browse files
authored
Code Quality: Fixed caused by useless predicate (#15126)
1 parent ba56951 commit 65e511d

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

src/Files.App (Package)/Package.appxmanifest

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@
168168
<ActivatableClass ActivatableClassId="Files.App.Server.AppInstanceMonitor" />
169169
<ActivatableClass ActivatableClassId="Files.App.Server.Database.FileTagsDatabase" />
170170
<ActivatableClass ActivatableClassId="Files.App.Server.Database.LayoutPreferencesDatabase" />
171-
<ActivatableClass ActivatableClassId="Files.App.Server.Database.LayoutPreferencesFilterPredicate" />
172171
<ActivatableClass ActivatableClassId="Files.App.Server.Database.LayoutPreferencesUpdateAction" />
173172
<ActivatableClass ActivatableClassId="Files.App.Server.Data.ColumnPreferences" />
174173
<ActivatableClass ActivatableClassId="Files.App.Server.Data.ColumnPreferencesItem" />

src/Files.App.Server/Database/LayoutPreferencesDatabase.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,18 @@ public void SetPreferences(string filePath, ulong? frn, LayoutPreferencesItem? p
7575
}
7676
}
7777

78-
public void ResetAll(LayoutPreferencesFilterPredicate? predicate)
78+
public void ResetAll()
7979
{
8080
var col = _database.GetCollection<LayoutPreferences>(LayoutPreferences);
8181

82-
if (predicate is null)
83-
{
84-
col.DeleteAll();
85-
}
86-
else
87-
{
88-
col.DeleteMany(x => predicate(x));
89-
}
82+
col.DeleteAll();
9083
}
9184

92-
public void ApplyToAll(LayoutPreferencesUpdateAction updateAction, LayoutPreferencesFilterPredicate? predicate)
85+
public void ApplyToAll(LayoutPreferencesUpdateAction updateAction)
9386
{
9487
var col = _database.GetCollection<LayoutPreferences>(LayoutPreferences);
9588

96-
var allDocs = predicate is null ? col.FindAll() : col.Find(x => predicate(x));
89+
var allDocs = col.FindAll();
9790

9891
foreach (var doc in allDocs)
9992
{
@@ -159,6 +152,5 @@ public string Export()
159152
}
160153
}
161154

162-
public delegate bool LayoutPreferencesFilterPredicate(LayoutPreferences preference);
163155
public delegate void LayoutPreferencesUpdateAction(LayoutPreferences preference);
164156
}

src/Files.App/Helpers/Layout/LayoutPreferencesDatabaseManager.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,14 @@ public void SetPreferences(string filePath, ulong? frn, LayoutPreferencesItem? p
135135
_database.SetPreferences(filePath, frn, ToDatabaseEntity(preferencesItem));
136136
}
137137

138-
public void ResetAll(Func<LayoutPreferencesDatabaseItem, bool>? predicate = null)
138+
public void ResetAll()
139139
{
140-
_database.ResetAll(item => predicate?.Invoke(FromDatabaseEntity(item)) ?? true);
140+
_database.ResetAll();
141141
}
142142

143-
public void ApplyToAll(Action<LayoutPreferencesDatabaseItem> updateAction, Func<LayoutPreferencesDatabaseItem, bool>? predicate = null)
143+
public void ApplyToAll(Action<LayoutPreferencesDatabaseItem> updateAction)
144144
{
145-
_database.ApplyToAll(item => updateAction.Invoke(FromDatabaseEntity(item)),
146-
item => predicate?.Invoke(FromDatabaseEntity(item)) ?? true);
145+
_database.ApplyToAll(item => updateAction.Invoke(FromDatabaseEntity(item)));
147146
}
148147

149148
public void Import(string json)

0 commit comments

Comments
 (0)