Thread viewer for Bluesky

finished loading quote count for thread root

+19 -20
+8 -1
src/components/posts/PostComponent.svelte
··· 39 39 40 40 setContext('post', { post, context }); 41 41 42 + // TODO: make Post reactive 43 + let quoteCount = $state(post.quoteCount); 44 + 45 + export function setQuoteCount(x) { 46 + quoteCount = x; 47 + } 48 + 42 49 function shouldRenderReply(reply) { 43 50 if (reply instanceof Post) { 44 51 return true; ··· 100 107 {/if} 101 108 102 109 {#if post.likeCount !== undefined || post.repostCount !== undefined} 103 - <PostFooter /> 110 + <PostFooter {quoteCount} /> 104 111 {/if} 105 112 {/snippet} 106 113
+5 -4
src/components/posts/PostFooter.svelte
··· 6 6 import { showError } from '../../utils.js'; 7 7 8 8 let { post, context } = getContext('post'); 9 + let { quoteCount } = $props(); 9 10 10 11 let isLiked = $state(post.liked); 11 12 let likeCount = $state(post.likeCount); ··· 78 79 </span> 79 80 {/if} 80 81 81 - {#if !post.isPageRoot && context != 'quote' && post.quoteCount} 82 - {#if context == 'quotes' || context == 'feed'} 82 + {#if quoteCount && context != 'quote'} 83 + {#if context == 'quotes' || context == 'feed' || post.isPageRoot} 83 84 <span> 84 85 <i class="fa-regular fa-comments"></i> 85 - <a href={linkToQuotesPage(post.linkToPost)}>{post.quoteCount > 1 ? `${post.quoteCount} quotes` : '1 quote'}</a> 86 + <a href={linkToQuotesPage(post.linkToPost)}>{quoteCount > 1 ? `${quoteCount} quotes` : '1 quote'}</a> 86 87 </span> 87 88 {:else} 88 89 <a href={linkToQuotesPage(post.linkToPost)}> 89 - <i class="fa-regular fa-comments"></i> {post.quoteCount} 90 + <i class="fa-regular fa-comments"></i> {quoteCount} 90 91 </a> 91 92 {/if} 92 93 {/if}
+6 -7
src/pages/ThreadPage.svelte
··· 22 22 throw 'Either url or author & rkey must be set'; 23 23 } 24 24 25 + let rootComponent; 26 + 25 27 response.then((json) => { 26 28 let root = parseThreadPost(json.thread); 27 29 window.root = root; 28 30 window.subtreeRoot = root; 29 31 30 32 if (root instanceof Post) { 31 - /* 32 - TODO 33 + root.data.quoteCount = undefined; 34 + 33 35 blueAPI.getQuoteCount(root.uri).then(count => { 34 - if (count > 0) { 35 - component.appendQuotesIconLink(count, true); 36 - } 36 + rootComponent.setQuoteCount(count); 37 37 }).catch(error => { 38 38 console.warn("Couldn't load quote count: " + error); 39 39 }); 40 - */ 41 40 } 42 41 43 42 post = root; ··· 62 61 {/if} 63 62 {/if} 64 63 65 - <PostComponent {post} context="thread" /> 64 + <PostComponent {post} context="thread" bind:this={rootComponent} /> 66 65 {:else if !loadingFailed} 67 66 <MainLoader /> 68 67 {/if}
-8
src/post_component.js
··· 76 76 $(node.parentNode).replaceChild(markedText, node); 77 77 } 78 78 } 79 - 80 - /** @param {number} quoteCount, @param {boolean} expanded */ 81 - 82 - appendQuotesIconLink(quoteCount, expanded) { 83 - /*let stats = $(this.rootElement.querySelector(':scope > .content > p.stats')); 84 - let quotesLink = this.buildQuotesIconLink(quoteCount, expanded); 85 - stats.append(quotesLink);*/ 86 - } 87 79 }