From 59c6f17e67351bac6f56a49e3655d0eff64fbb68 Mon Sep 17 00:00:00 2001 From: Jason Schwarzenberger Date: Wed, 2 Dec 2020 13:22:47 +1300 Subject: [PATCH] gotta try this on live. --- apiserver/search.py | 4 ++-- apiserver/server.py | 4 +++- webapp/src/components/Comment.svelte | 9 +++------ webapp/src/components/StoryInfo.svelte | 2 +- webapp/src/routes/[id].svelte | 6 ++++-- webclient/src/pages/Results.js | 5 ++++- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/apiserver/search.py b/apiserver/search.py index 62db610..3f28f75 100644 --- a/apiserver/search.py +++ b/apiserver/search.py @@ -67,9 +67,9 @@ def put_story(story): logging.error('Problem putting MeiliSearch story: {}'.format(str(e))) return False -def search(q): +def search(q, skip=0, limit=250): try: - params = dict(q=q, limit=250) + params = dict(q=q, skip=skip, limit=limit) r = requests.get(MEILI_URL + 'indexes/qotnews/search', params=params, timeout=2) if r.status_code != 200: raise Exception('Bad response code ' + str(r.status_code)) diff --git a/apiserver/server.py b/apiserver/server.py index 29e2c45..ba98f30 100644 --- a/apiserver/server.py +++ b/apiserver/server.py @@ -51,8 +51,10 @@ def api(): @flask_app.route('/api/search', strict_slashes=False) def apisearch(): q = request.args.get('q', '') + skip = request.args.get('skip', 0) + limit = request.args.get('limit', 20) if len(q) >= 3: - results = search.search(q) + results = search.search(q, skip=skip, limit=limit) else: results = [] return dict(results=results) diff --git a/webapp/src/components/Comment.svelte b/webapp/src/components/Comment.svelte index b343949..55c15ef 100644 --- a/webapp/src/components/Comment.svelte +++ b/webapp/src/components/Comment.svelte @@ -54,10 +54,6 @@ overflow: hidden; color: #888; } - .comment-text.is-collapsed::after { - content: "..."; - font-style: italic; - } .comment-children { margin-left: 0.5rem; padding-left: 0.5rem; @@ -85,14 +81,15 @@
{comment.author || '[Deleted]'} - • {#if comment.comments.length} + on:click={toggleComments}>{#if showComments} + [–] + {:else}[+]{/if} {/if}
diff --git a/webapp/src/components/StoryInfo.svelte b/webapp/src/components/StoryInfo.svelte index 63e41f2..9f2f186 100644 --- a/webapp/src/components/StoryInfo.svelte +++ b/webapp/src/components/StoryInfo.svelte @@ -11,7 +11,7 @@ on {story.source} {#if story.score}• {story.score} points{/if} -{#if story.num_comments} +{#if Number(story.num_comments)} • {story.num_comments} comments diff --git a/webapp/src/routes/[id].svelte b/webapp/src/routes/[id].svelte index 30c71a7..957e463 100644 --- a/webapp/src/routes/[id].svelte +++ b/webapp/src/routes/[id].svelte @@ -18,8 +18,10 @@ export let story; export let related; - let others = related.filter((r) => r.id !== story.id && r.num_comments); - let hasComments = related.some((r) => r.num_comments); + let others = related.filter( + (r) => r.id !== story.id && Number(r.num_comments) + ); + let hasComments = related.some((r) => Number(r.num_comments));