remove stupid idea.

This commit is contained in:
Jason Schwarzenberger 2020-11-27 13:54:25 +13:00
parent fe4b02e8a1
commit da62f8859b

View File

@ -6,18 +6,7 @@
const data = await res.json(); const data = await res.json();
if (res.status === 200) { if (res.status === 200) {
const related = []; return { story: data.story, related: data.related };
const others = data.related.filter(
(r) => r.id !== data.story.id && !!r.num_comments
);
for (const other of others) {
const r = await this.fetch(`${other.id}.json`);
if (r.ok) {
const d = await r.json();
related.push(d.story);
}
}
return { story: data.story, related };
} else { } else {
this.error(res.status, data.message); this.error(res.status, data.message);
} }
@ -30,7 +19,7 @@
export let story; export let story;
export let related; export let related;
let hasComments = story.num_comments || related.length; let hasComments = related.some((r) => r.num_comments);
</script> </script>
<style> <style>
@ -95,7 +84,7 @@
<h3> <h3>
Other discussions: Other discussions:
{#each related as r} {#each related as r}
{#if r.num_comments} {#if r.num_comments && r.id !== story.id}
<a href="/{r.id}#comments" rel="prefetch">{r.source}</a> <a href="/{r.id}#comments" rel="prefetch">{r.source}</a>
{/if} {/if}
{/each} {/each}