From 1ff7cd7290e0247fd56b9789eea09e3f092ae7ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tao=20Bojl=C3=A9n?= <2803708-taobojlen@users.noreply.gitlab.com> Date: Tue, 23 Jul 2019 14:08:43 +0000 Subject: [PATCH] frontend/search/ui fixes --- backend/config/dev.exs | 2 +- backend/lib/backend_web/views/search_view.ex | 13 +++++++++++-- frontend/src/components/screens/InstanceScreen.tsx | 7 ++++--- frontend/src/components/screens/SearchScreen.tsx | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/backend/config/dev.exs b/backend/config/dev.exs index c58a4ca..d4dcaa1 100644 --- a/backend/config/dev.exs +++ b/backend/config/dev.exs @@ -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: [ diff --git a/backend/lib/backend_web/views/search_view.ex b/backend/lib/backend_web/views/search_view.ex index a44ab5a..0be3fe7 100644 --- a/backend/lib/backend_web/views/search_view.ex +++ b/backend/lib/backend_web/views/search_view.ex @@ -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 diff --git a/frontend/src/components/screens/InstanceScreen.tsx b/frontend/src/components/screens/InstanceScreen.tsx index 59c01e0..b12d3c0 100644 --- a/frontend/src/components/screens/InstanceScreen.tsx +++ b/frontend/src/components/screens/InstanceScreen.tsx @@ -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) => { - if (event.key === "Enter") { + if (event.key === "Enter" && this.state.currentQuery !== this.props.query) { this.search(); } };