Skip to content

Commit 10a30f4

Browse files
committed
move exception result into its own method
1 parent 8df4bb2 commit 10a30f4

File tree

1 file changed

+42
-37
lines changed
  • Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex

1 file changed

+42
-37
lines changed

Plugins/Flow.Launcher.Plugin.Explorer/Search/WindowsIndex/IndexSearch.cs

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -112,43 +112,7 @@ await ExecuteWindowsIndexSearchAsync(constructedQuery, queryHelper().ConnectionS
112112
if (!SearchManager.Settings.WarnWindowsSearchServiceOff)
113113
return new List<Result>();
114114

115-
var api = SearchManager.Context.API;
116-
117-
return new List<Result>
118-
{
119-
new Result
120-
{
121-
Title = api.GetTranslation("plugin_explorer_windowsSearchServiceNotRunning"),
122-
SubTitle = api.GetTranslation("plugin_explorer_windowsSearchServiceFix"),
123-
Action = c =>
124-
{
125-
SearchManager.Settings.WarnWindowsSearchServiceOff = false;
126-
127-
if (MessageBox.Show(string.Format(api.GetTranslation("plugin_explorer_alternative"), Environment.NewLine),
128-
api.GetTranslation("plugin_explorer_alternative_title"),
129-
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
130-
{
131-
var pluginsManagerPlugins= api.GetAllPlugins().FirstOrDefault(x => x.Metadata.ID == "9f8f9b14-2518-4907-b211-35ab6290dee7");
132-
133-
api.ChangeQuery(string.Format("{0} install everything", pluginsManagerPlugins.Metadata.ActionKeywords[0]));
134-
}
135-
else
136-
{
137-
// Clears the warning message because same query string will not alter the displayed result list
138-
api.ChangeQuery(string.Empty);
139-
140-
api.ChangeQuery(query.RawQuery);
141-
}
142-
143-
var mainWindow = Application.Current.MainWindow;
144-
mainWindow.Visibility = Visibility.Visible;
145-
mainWindow.Focus();
146-
147-
return false;
148-
},
149-
IcoPath = Constants.ExplorerIconImagePath
150-
}
151-
};
115+
return ResultForWindexSearchOff(query.RawQuery);
152116
}
153117
}
154118

@@ -200,6 +164,47 @@ internal static bool PathIsIndexed(string path)
200164
}
201165
}
202166

167+
private static List<Result> ResultForWindexSearchOff(string rawQuery)
168+
{
169+
var api = SearchManager.Context.API;
170+
171+
return new List<Result>
172+
{
173+
new Result
174+
{
175+
Title = api.GetTranslation("plugin_explorer_windowsSearchServiceNotRunning"),
176+
SubTitle = api.GetTranslation("plugin_explorer_windowsSearchServiceFix"),
177+
Action = c =>
178+
{
179+
SearchManager.Settings.WarnWindowsSearchServiceOff = false;
180+
181+
if (MessageBox.Show(string.Format(api.GetTranslation("plugin_explorer_alternative"), Environment.NewLine),
182+
api.GetTranslation("plugin_explorer_alternative_title"),
183+
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
184+
{
185+
var pluginsManagerPlugins= api.GetAllPlugins().FirstOrDefault(x => x.Metadata.ID == "9f8f9b14-2518-4907-b211-35ab6290dee7");
186+
187+
api.ChangeQuery(string.Format("{0} install everything", pluginsManagerPlugins.Metadata.ActionKeywords[0]));
188+
}
189+
else
190+
{
191+
// Clears the warning message because same query string will not alter the displayed result list
192+
api.ChangeQuery(string.Empty);
193+
194+
api.ChangeQuery(rawQuery);
195+
}
196+
197+
var mainWindow = Application.Current.MainWindow;
198+
mainWindow.Visibility = Visibility.Visible;
199+
mainWindow.Focus();
200+
201+
return false;
202+
},
203+
IcoPath = Constants.ExplorerIconImagePath
204+
}
205+
};
206+
}
207+
203208
private static void LogException(string message, Exception e)
204209
{
205210
#if DEBUG // Please investigate and handle error from index search

0 commit comments

Comments
 (0)