tangled
alpha
login
or
join now
mackuba.eu
/
skythread
14
fork
atom
Thread viewer for Bluesky
14
fork
atom
overview
issues
pulls
pipelines
finished loading quote count for thread root
mackuba.eu
3 months ago
e6096f63
69d2c495
+19
-20
4 changed files
expand all
collapse all
unified
split
src
components
posts
PostComponent.svelte
PostFooter.svelte
pages
ThreadPage.svelte
post_component.js
+8
-1
src/components/posts/PostComponent.svelte
···
39
39
40
40
setContext('post', { post, context });
41
41
42
42
+
// TODO: make Post reactive
43
43
+
let quoteCount = $state(post.quoteCount);
44
44
+
45
45
+
export function setQuoteCount(x) {
46
46
+
quoteCount = x;
47
47
+
}
48
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
103
-
<PostFooter />
110
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
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
81
-
{#if !post.isPageRoot && context != 'quote' && post.quoteCount}
82
82
-
{#if context == 'quotes' || context == 'feed'}
82
82
+
{#if quoteCount && context != 'quote'}
83
83
+
{#if context == 'quotes' || context == 'feed' || post.isPageRoot}
83
84
<span>
84
85
<i class="fa-regular fa-comments"></i>
85
85
-
<a href={linkToQuotesPage(post.linkToPost)}>{post.quoteCount > 1 ? `${post.quoteCount} quotes` : '1 quote'}</a>
86
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
89
-
<i class="fa-regular fa-comments"></i> {post.quoteCount}
90
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
25
+
let rootComponent;
26
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
31
-
/*
32
32
-
TODO
33
33
+
root.data.quoteCount = undefined;
34
34
+
33
35
blueAPI.getQuoteCount(root.uri).then(count => {
34
34
-
if (count > 0) {
35
35
-
component.appendQuotesIconLink(count, true);
36
36
-
}
36
36
+
rootComponent.setQuoteCount(count);
37
37
}).catch(error => {
38
38
console.warn("Couldn't load quote count: " + error);
39
39
});
40
40
-
*/
41
40
}
42
41
43
42
post = root;
···
62
61
{/if}
63
62
{/if}
64
63
65
65
-
<PostComponent {post} context="thread" />
64
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
79
-
80
80
-
/** @param {number} quoteCount, @param {boolean} expanded */
81
81
-
82
82
-
appendQuotesIconLink(quoteCount, expanded) {
83
83
-
/*let stats = $(this.rootElement.querySelector(':scope > .content > p.stats'));
84
84
-
let quotesLink = this.buildQuotesIconLink(quoteCount, expanded);
85
85
-
stats.append(quotesLink);*/
86
86
-
}
87
79
}