Skip to content

Commit 02e0b76

Browse files
committed
Honor the 'remove all desktop shortcuts' setting
1 parent 08e2b4c commit 02e0b76

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

src/UniGetUI.PackageEngine.PackageManagerClasses/Packages/Classes/DesktopShortcutsDatabase.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,27 @@ public static List<string> GetUnknownShortcuts()
155155
/// <param name="PreviousShortCutList"></param>
156156
public static void TryRemoveNewShortcuts(IReadOnlyList<string> PreviousShortCutList)
157157
{
158-
HashSet<string> ShortcutSet = PreviousShortCutList.ToHashSet();
159-
List<string> CurrentShortcutList = DesktopShortcutsDatabase.GetShortcuts();
158+
HashSet<string> ShortcutSet = [.. PreviousShortCutList];
159+
List<string> CurrentShortcutList = GetShortcuts();
160160
foreach (string shortcut in CurrentShortcutList)
161161
{
162162
if (ShortcutSet.Contains(shortcut)) continue;
163-
switch (DesktopShortcutsDatabase.GetStatus(shortcut))
163+
switch (GetStatus(shortcut))
164164
{
165165
case Status.Delete:
166-
DesktopShortcutsDatabase.DeleteFromDisk(shortcut);
166+
DeleteFromDisk(shortcut);
167167
break;
168168
case Status.Maintain:
169169
Logger.Debug("Refraining from deleting new shortcut " + shortcut + ": user disabled its deletion");
170170
break;
171171
case Status.Unknown:
172+
if (Settings.Get("RemoveAllDesktopShortcuts"))
173+
{
174+
AddToDatabase(shortcut, true);
175+
DeleteFromDisk(shortcut);
176+
RemoveFromUnknownShortcuts(shortcut);
177+
break;
178+
}
172179
if (UnknownShortcuts.Contains(shortcut)) continue;
173180
Logger.Info("Marking the shortcut " + shortcut + " to be asked to be deleted");
174181
UnknownShortcuts.Add(shortcut);

src/UniGetUI/Pages/DialogPages/DesktopShortcuts.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
</Grid.ColumnDefinitions>
4545
<TextBlock
4646
Grid.ColumnSpan="2"
47-
Text="Existing shortcuts on your desktop will be scanned, and you will need to pick which ones to keep and which ones to remove."
47+
Text="Existing shortcuts on your desktop will be scanned, and you will need to pick which ones to keep and which ones to remove. If 'Delete all desktop shortcuts after an install or upgrade' is enabled, they will be deleted automatically."
4848
Margin="0,0,0,0"
4949
TextWrapping="WrapWholeWords"
5050
/>

src/UniGetUI/Pages/DialogPages/DesktopShortcuts.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,13 @@ private void DeletableDesktopShortcutsList_DoubleTapped(object sender, DoubleTap
9090
private async void ManualScanButton_Click(object sender, RoutedEventArgs e)
9191
{
9292
DesktopShortcutsDatabase.TryRemoveNewShortcuts([]);
93-
Close?.Invoke(this, EventArgs.Empty);
93+
SaveChangesAndClose();
9494
var shortcuts = DesktopShortcutsDatabase.GetUnknownShortcuts();
9595
if (shortcuts.Any())
9696
{
9797
await DialogHelper.ManageDesktopShortcuts(shortcuts);
9898
}
99-
else
99+
else if (!Settings.Get("RemoveAllDesktopShortcuts"))
100100
{
101101
await DialogHelper.NoDesktopShortcutsFound();
102102
}

0 commit comments

Comments
 (0)