Skip to content

Commit

Permalink
Fixing web search
Browse files Browse the repository at this point in the history
  • Loading branch information
marigostra committed Jun 8, 2022
1 parent 86e49e0 commit 3c90528
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
8 changes: 5 additions & 3 deletions src/main/java/org/luwrain/io/WebCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ public final class WebCommand implements Command
if (res instanceof Boolean)
{
final Boolean bool = (Boolean)res;
if (bool.booleanValue())
if (!bool.booleanValue())
new WebSearch(luwrain).searchAsync(query);
return;
}
if (!(res instanceof WebSearchResult))
return;
final WebSearchResult webSearchResult = (WebSearchResult)res;
if (webSearchResult.getItemCount() == 0)
final WebSearchResult webSearchResult = (WebSearchResult)res;
if (webSearchResult.noItems())
{
luwrain.message(luwrain.i18n().getStaticStr("NothingFound"), Luwrain.MessageType.DONE);
return;
Expand All @@ -64,6 +65,7 @@ public final class WebCommand implements Command
if (item == null)
return;
luwrain.openUrl(item.getClickUrl());
return;
}

private Object runWebOpenHook(Luwrain luwrain, String query)
Expand Down
14 changes: 3 additions & 11 deletions src/main/java/org/luwrain/io/WebSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,10 @@ public void searchAsync(String query, Consumer<Object> resultHandler)
{
NullCheck.notEmpty(query, "query");
NullCheck.notNull(resultHandler, "resultHandler");
luwrain.executeBkg(new FutureTask<>(()->{
final Object res;
try {
res = runWebSearchHook(luwrain, query);
}
catch(Throwable e)
{
luwrain.crash(e);
return;
}
luwrain.executeBkg(()->{
final Object res = runWebSearchHook(luwrain, query);
luwrain.runUiSafely(()->resultHandler.accept(res));
}, null));
});
}

public void searchAsync(String query)
Expand Down

0 comments on commit 3c90528

Please sign in to comment.