-
-
Notifications
You must be signed in to change notification settings - Fork 465
Fix hide item option not working in Program plugin #4141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from 4 commits
4101e34
07294aa
14369d8
ad254be
288ac47
2d44676
8c4979d
3a59a53
96a12a8
621dbc1
6a5de0b
d419819
70519da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,10 +42,10 @@ | |
| { | ||
| "uninst.exe", | ||
| "unins000.exe", | ||
| "uninst000.exe", | ||
| "uninstall.exe" | ||
| }; | ||
| private static readonly string[] commonUninstallerPrefixs = | ||
| { | ||
| "uninstall",//en | ||
| "卸载",//zh-cn | ||
|
|
@@ -61,9 +61,9 @@ | |
| "삭제",//ko | ||
| "деинсталирај",//sr | ||
| "desinstalar",//pt-pt | ||
| "desinstalar",//pt-br | ||
| "desinstalar",//es | ||
| "desinstalar",//es-419 | ||
| "disinstallare",//it | ||
| "avinstallere",//nb-NO | ||
| "odinštalovať",//sk | ||
|
|
@@ -73,7 +73,7 @@ | |
| "gỡ bỏ",//vi-vn | ||
| "הסרה"//he | ||
| }; | ||
| private const string ExeUninstallerSuffix = ".exe"; | ||
| private const string InkUninstallerSuffix = ".lnk"; | ||
|
|
||
| private static readonly string WindowsAppPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "WindowsApps"); | ||
|
|
@@ -334,7 +334,7 @@ | |
| } | ||
| } | ||
|
|
||
| public static async Task IndexWin32ProgramsAsync() | ||
| public static async Task IndexWin32ProgramsAsync(bool resetCache = true) | ||
| { | ||
| await _win32sLock.WaitAsync(); | ||
| try | ||
|
|
@@ -345,7 +345,10 @@ | |
| { | ||
| _win32s.Add(win32); | ||
| } | ||
| ResetCache(); | ||
| if (resetCache) | ||
| { | ||
| ResetCache(); | ||
| } | ||
| await Context.API.SaveCacheBinaryStorageAsync<List<Win32>>(Win32CacheName, Context.CurrentPluginMetadata.PluginCacheDirectoryPath); | ||
| lock (_lastIndexTimeLock) | ||
| { | ||
|
|
@@ -362,7 +365,7 @@ | |
| } | ||
| } | ||
|
|
||
| public static async Task IndexUwpProgramsAsync() | ||
| public static async Task IndexUwpProgramsAsync(bool resetCache = true) | ||
| { | ||
| await _uwpsLock.WaitAsync(); | ||
| try | ||
|
|
@@ -373,7 +376,10 @@ | |
| { | ||
| _uwps.Add(uwp); | ||
| } | ||
| ResetCache(); | ||
| if (resetCache) | ||
| { | ||
| ResetCache(); | ||
| } | ||
| await Context.API.SaveCacheBinaryStorageAsync<List<UWPApp>>(UwpCacheName, Context.CurrentPluginMetadata.PluginCacheDirectoryPath); | ||
| lock (_lastIndexTimeLock) | ||
| { | ||
|
|
@@ -394,12 +400,12 @@ | |
| { | ||
| var win32Task = Task.Run(async () => | ||
| { | ||
| await Context.API.StopwatchLogInfoAsync(ClassName, "Win32Program index cost", IndexWin32ProgramsAsync); | ||
| await Context.API.StopwatchLogInfoAsync(ClassName, "Win32Program index cost", () => IndexWin32ProgramsAsync(true)); | ||
| }); | ||
|
|
||
| var uwpTask = Task.Run(async () => | ||
| { | ||
| await Context.API.StopwatchLogInfoAsync(ClassName, "UWPProgram index cost", IndexUwpProgramsAsync); | ||
| await Context.API.StopwatchLogInfoAsync(ClassName, "UWPProgram index cost", () => IndexUwpProgramsAsync(true)); | ||
Jack251970 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }); | ||
|
|
||
| await Task.WhenAll(win32Task, uwpTask).ConfigureAwait(false); | ||
|
|
@@ -442,12 +448,25 @@ | |
| Title = Context.API.GetTranslation("flowlauncher_plugin_program_disable_program"), | ||
| Action = c => | ||
| { | ||
| _ = DisableProgramAsync(program); | ||
| Context.API.ShowMsg( | ||
| Context.API.GetTranslation("flowlauncher_plugin_program_disable_dlgtitle_success"), | ||
| Context.API.GetTranslation( | ||
| "flowlauncher_plugin_program_disable_dlgtitle_success_message")); | ||
| Context.API.ReQuery(); | ||
| _ = Task.Run(async () => | ||
| { | ||
| try | ||
| { | ||
| if (await DisableProgramAsync(program)) | ||
| { | ||
| ResetCache(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does the ResetCache call work when we are resetting multiple times ? For example user disables one program after another.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No idea about what you said. Every time one program is disabled, it will invoke a task to add the program in disable list and reindex.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
It will reset the cache every time you disable a program. The one elegant way is to only remove the cache entry of the disabled one. But yeah calling resetting cache one by one is acceptable imo. |
||
| } | ||
| Context.API.ShowMsg( | ||
| Context.API.GetTranslation("flowlauncher_plugin_program_disable_dlgtitle_success"), | ||
| Context.API.GetTranslation( | ||
| "flowlauncher_plugin_program_disable_dlgtitle_success_message")); | ||
| Context.API.ReQuery(); | ||
| } | ||
| catch (Exception e) | ||
| { | ||
| Context.API.LogException(ClassName, "Failed to disable program", e); | ||
| } | ||
| }); | ||
Jack251970 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return false; | ||
| }, | ||
| IcoPath = "Images/disable.png", | ||
|
|
@@ -458,52 +477,48 @@ | |
| return menuOptions; | ||
| } | ||
|
|
||
| private static async Task DisableProgramAsync(IProgram programToDelete) | ||
| private static async Task<bool> DisableProgramAsync(IProgram programToDelete) | ||
| { | ||
| if (_settings.DisabledProgramSources.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier)) | ||
| return; | ||
| return false; | ||
|
|
||
| await _uwpsLock.WaitAsync(); | ||
| var reindexUwps = true; | ||
| try | ||
| { | ||
| reindexUwps = _uwps.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier); | ||
| var program = _uwps.First(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier); | ||
| program.Enabled = false; | ||
| _settings.DisabledProgramSources.Add(new ProgramSource(program)); | ||
| var program = _uwps.FirstOrDefault(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier); | ||
| if (program != null) | ||
| { | ||
| program.Enabled = false; | ||
| _settings.DisabledProgramSources.Add(new ProgramSource(program)); | ||
| // Reindex UWP programs | ||
| _ = Task.Run(() => IndexUwpProgramsAsync(false)); | ||
Jack251970 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return true; | ||
| } | ||
| } | ||
| finally | ||
| { | ||
| _uwpsLock.Release(); | ||
| } | ||
|
|
||
| // Reindex UWP programs | ||
| if (reindexUwps) | ||
| { | ||
| _ = Task.Run(IndexUwpProgramsAsync); | ||
| return; | ||
| } | ||
|
|
||
| await _win32sLock.WaitAsync(); | ||
| var reindexWin32s = true; | ||
| try | ||
| { | ||
| reindexWin32s = _win32s.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier); | ||
| var program = _win32s.First(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier); | ||
| program.Enabled = false; | ||
| _settings.DisabledProgramSources.Add(new ProgramSource(program)); | ||
| var program = _win32s.FirstOrDefault(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier); | ||
| if (program != null) | ||
| { | ||
| program.Enabled = false; | ||
| _settings.DisabledProgramSources.Add(new ProgramSource(program)); | ||
| // Reindex Win32 programs | ||
| _ = Task.Run(() => IndexWin32ProgramsAsync(false)); | ||
Jack251970 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return true; | ||
| } | ||
| } | ||
| finally | ||
| { | ||
| _win32sLock.Release(); | ||
| } | ||
|
|
||
| // Reindex Win32 programs | ||
| if (reindexWin32s) | ||
| { | ||
| _ = Task.Run(IndexWin32ProgramsAsync); | ||
| return; | ||
| } | ||
| return false; | ||
| } | ||
Jack251970 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| public static void StartProcess(Func<ProcessStartInfo, Process> runProcess, ProcessStartInfo info) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.