frontend/search/ui fixes

This commit is contained in:
Tao Bojlén 2019-07-23 14:08:43 +00:00
parent 6673a24466
commit 1ff7cd7290
4 changed files with 17 additions and 7 deletions

View File

@ -59,7 +59,7 @@ config :backend, Backend.Repo,
config :backend, :crawler,
status_age_limit_days: 28,
status_count_limit: 100,
personal_instance_threshold: 1,
personal_instance_threshold: 5,
crawl_interval_mins: 1,
crawl_workers: 10,
blacklist: [

View File

@ -1,7 +1,7 @@
defmodule BackendWeb.SearchView do
use BackendWeb, :view
alias BackendWeb.SearchView
require Logger
import Backend.Util
def render("index.json", %{instances: instances, next: next}) do
%{
@ -11,9 +11,18 @@ defmodule BackendWeb.SearchView do
end
def render("instance.json", %{instance: instance}) do
threshold = get_config(:personal_instance_threshold)
description =
if instance.user_count != nil and instance.user_count < threshold do
nil
else
instance.description
end
%{
name: instance.domain,
description: instance.description,
description: description,
userCount: instance.user_count
}
end

View File

@ -72,7 +72,6 @@ interface IInstanceScreenProps {
isLoadingInstanceDetails: boolean;
navigateToRoot: () => void;
}
interface IInstanceScreenState {
neighbors?: string[];
isProcessingNeighbors: boolean;
@ -119,8 +118,10 @@ class InstanceScreenImpl extends React.PureComponent<IInstanceScreenProps, IInst
this.processEdgesToFindNeighbors();
}
public componentDidUpdate(prevProps: IInstanceScreenProps, prevState: IInstanceScreenState) {
if (prevProps.instanceName !== this.props.instanceName) {
public componentDidUpdate(prevProps: IInstanceScreenProps) {
const isNewInstance = prevProps.instanceName !== this.props.instanceName;
const receivedNewEdges = !!this.props.graph && !this.state.isProcessingNeighbors && !this.state.neighbors;
if (isNewInstance || receivedNewEdges) {
this.processEdgesToFindNeighbors();
}
}

View File

@ -90,7 +90,7 @@ class SearchScreen extends React.PureComponent<ISearchScreenProps, ISearchScreen
};
private handleKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {
if (event.key === "Enter") {
if (event.key === "Enter" && this.state.currentQuery !== this.props.query) {
this.search();
}
};