Skip to content
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
34 changes: 19 additions & 15 deletions Plugins/Flow.Launcher.Plugin.Program/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,35 +88,42 @@ public async Task InitAsync(PluginInitContext context)

bool cacheEmpty = !_win32s.Any() && !_uwps.Any();

var a = Task.Run(() =>
if (cacheEmpty || _settings.LastIndexTime.AddHours(30) < DateTime.Now)
{
Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|Win32Program index cost", IndexWin32Programs);
});

var b = Task.Run(() =>
_ = Task.Run(async () =>
{
await IndexProgramsAsync().ConfigureAwait(false);
WatchProgramUpdate();
});
}
else
{
Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|UWPPRogram index cost", IndexUwpPrograms);
});

if (cacheEmpty)
await Task.WhenAll(a, b);
WatchProgramUpdate();
}

Win32.WatchProgramUpdate(_settings);
_ = UWP.WatchPackageChange();
static void WatchProgramUpdate()
{
Win32.WatchProgramUpdate(_settings);
_ = UWP.WatchPackageChange();
}
}

public static void IndexWin32Programs()
{
var win32S = Win32.All(_settings);
_win32s = win32S;
ResetCache();
_win32Storage.Save(_win32s);
_settings.LastIndexTime = DateTime.Now;
}

public static void IndexUwpPrograms()
{
var applications = UWP.All(_settings);
_uwps = applications;
ResetCache();
_uwpStorage.Save(_uwps);
_settings.LastIndexTime = DateTime.Now;
}

public static async Task IndexProgramsAsync()
Expand All @@ -131,7 +138,6 @@ public static async Task IndexProgramsAsync()
Stopwatch.Normal("|Flow.Launcher.Plugin.Program.Main|UWPProgram index cost", IndexUwpPrograms);
});
await Task.WhenAll(a, b).ConfigureAwait(false);
_settings.LastIndexTime = DateTime.Today;
}

internal static void ResetCache()
Expand Down Expand Up @@ -199,7 +205,6 @@ private static void DisableProgram(IProgram programToDelete)
_ = Task.Run(() =>
{
IndexUwpPrograms();
_settings.LastIndexTime = DateTime.Today;
});
}
else if (_win32s.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier))
Expand All @@ -210,7 +215,6 @@ private static void DisableProgram(IProgram programToDelete)
_ = Task.Run(() =>
{
IndexWin32Programs();
_settings.LastIndexTime = DateTime.Today;
});
}
}
Expand Down
7 changes: 0 additions & 7 deletions Plugins/Flow.Launcher.Plugin.Program/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,6 @@ private void RemoveRedundantSuffixes()
public bool EnablePathSource { get; set; } = false;
public bool EnableUWP { get; set; } = true;

public string CustomizedExplorer { get; set; } = Explorer;
public string CustomizedArgs { get; set; } = ExplorerArgs;

internal const char SuffixSeparator = ';';

internal const string Explorer = "explorer";

internal const string ExplorerArgs = "%s";
}
}
12 changes: 0 additions & 12 deletions Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,6 @@ public bool EnableUWP
}
}

public string CustomizedExplorerPath
{
get => _settings.CustomizedExplorer;
set => _settings.CustomizedExplorer = value;
}

public string CustomizedExplorerArg
{
get => _settings.CustomizedArgs;
set => _settings.CustomizedArgs = value;
}

public bool ShowUWPCheckbox => UWP.SupportUWP();

public ProgramSetting(PluginInitContext context, Settings settings, Win32[] win32s, UWP.Application[] uwps)
Expand Down