Skip to content

Commit

Permalink
fix: show message that the plugin is still trying to initialize and r…
Browse files Browse the repository at this point in the history
…emove automatic GitHub issue link
  • Loading branch information
Quriz committed Aug 7, 2024
1 parent 2b1f3a0 commit e8503ca
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 31 deletions.
19 changes: 5 additions & 14 deletions Community.PowerToys.Run.Plugin.Scoop/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ public class Main : IPlugin, IPluginI18n, IDelayedExecutionPlugin, IContextMenu,

public static string PluginID => "be0142a36ee54bd6ab789086d5828b4b";

private static readonly CompositeFormat RepositoryNewIssueUrlFormat = CompositeFormat.Parse("https://github.com/Quriz/PowerToysRunScoop/issues/new?labels=bug&title={0}&body={1}");
private static readonly CompositeFormat PluginNoResultFormat = CompositeFormat.Parse(Properties.Resources.plugin_no_result);
private static readonly CompositeFormat ErrorHomepageFormat = CompositeFormat.Parse(Properties.Resources.error_homepage);

private Action<string> onPluginError = null!;

private Scoop _scoop = null!;
private Exception _initException = null!;
private bool _isInitializing = false;

private PluginInitContext _context = null!;
Expand Down Expand Up @@ -89,7 +87,7 @@ private async void InitScoop()
}
catch (Exception e)
{
_initException = e;
// ignored
}

// Wait 30s before retrying
Expand All @@ -111,7 +109,7 @@ public List<Result> Query(Query query, bool delayedExecution)
if (!_scoop.IsInitialized)
{
Task.Run(InitScoop);
return InitErrorQueryResult();
return IsInitializingQueryResult();
}

if (!delayedExecution || query is null || string.IsNullOrWhiteSpace(query.Search))
Expand Down Expand Up @@ -151,23 +149,16 @@ private List<Result> ScoopNotInstalledQueryResult()
];
}

private List<Result> InitErrorQueryResult()
private List<Result> IsInitializingQueryResult()
{
return
[
new Result
{
Title = Properties.Resources.error_init,
SubTitle = Properties.Resources.error_init_sub,
Title = Properties.Resources.is_init,
SubTitle = Properties.Resources.is_init_sub,
QueryTextDisplay = " ", // Empty string doesn't work
IcoPath = _iconPath,
Action = _ =>
{
// Create a new issue describing the error
var title = HttpUtility.UrlEncode("Bug: Initialization Failed");
var body = HttpUtility.UrlEncode(_initException?.ToString());
return OpenUrlInBrowser(string.Format(CultureInfo.CurrentCulture, RepositoryNewIssueUrlFormat, title, body));
},
},
];
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@
<data name="plugin_description_sub" xml:space="preserve">
<value>Search, install, update, and uninstall Scoop packages.</value>
</data>
<data name="error_init" xml:space="preserve">
<value>Failed to initialize plugin.</value>
<data name="is_init" xml:space="preserve">
<value>Plugin is initializing.</value>
</data>
<data name="error_init_sub" xml:space="preserve">
<value>If you believe this is a plugin error, press Enter to open an issue.</value>
<data name="is_init_sub" xml:space="preserve">
<value>If you think this is a plugin bug, please open an issue on GitHub.</value>
</data>
<data name="message_add_bucket" xml:space="preserve">
<value>To install this package, you need to add the bucket '{0}'. Do you want to continue?</value>
Expand Down
2 changes: 1 addition & 1 deletion Community.PowerToys.Run.Plugin.Scoop/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"IsGlobal": false,
"Name": "Scoop",
"Author": "Quriz",
"Version": "1.3.2",
"Version": "1.3.3",
"Language": "csharp",
"Website": "https://github.com/Quriz/PowerToysRunScoop",
"IcoPathDark": "Images\\scoop.png",
Expand Down

0 comments on commit e8503ca

Please sign in to comment.