mirror of
https://github.com/PrimalHQ/primal-web-app.git
synced 2024-09-30 00:41:09 +00:00
Add reading estimate
This commit is contained in:
parent
b4b51a242d
commit
254499a4e4
@ -152,6 +152,13 @@
|
||||
font-weight: 700;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
.estimate {
|
||||
color: var(--text-tertiary);
|
||||
font-size: 15px;
|
||||
font-weight: 400;
|
||||
line-height: 24px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.image {
|
||||
|
@ -44,6 +44,9 @@ const ArticlePreview: Component<{
|
||||
<div class={styles.title}>
|
||||
{props.article.title}
|
||||
</div>
|
||||
<div class={styles.estimate}>
|
||||
{Math.ceil(props.article.wordCount / 238)} minutes
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Show when={props.article.image.length > 0}>
|
||||
|
@ -196,6 +196,7 @@ export const fetchArticles = (pubkey: string | undefined, noteIds: string[], sub
|
||||
topZaps: {},
|
||||
since: 0,
|
||||
until: 0,
|
||||
wordCount: {},
|
||||
}
|
||||
|
||||
const events = noteIds.reduce<EventCoordinate[]>((acc, id) => {
|
||||
@ -231,7 +232,6 @@ export const fetchArticles = (pubkey: string | undefined, noteIds: string[], sub
|
||||
});
|
||||
|
||||
getParametrizedEvents(events, subId);
|
||||
// getEvents(pubkey, [...noteIds], subId, true);
|
||||
|
||||
const updatePage = (content: NostrEventContent) => {
|
||||
if (content.kind === Kind.Metadata) {
|
||||
@ -358,6 +358,17 @@ export const fetchArticles = (pubkey: string | undefined, noteIds: string[], sub
|
||||
return;
|
||||
}
|
||||
|
||||
if (content.kind === Kind.WordCount) {
|
||||
const count = JSON.parse(content.content) as { event_id: string, words: number };
|
||||
|
||||
if (!page.wordCount) {
|
||||
page.wordCount = {};
|
||||
}
|
||||
|
||||
page.wordCount[count.event_id] = count.words
|
||||
return;
|
||||
}
|
||||
|
||||
if (content.kind === Kind.NoteQuoteStats) {
|
||||
const quoteStats = JSON.parse(content.content);
|
||||
|
||||
@ -384,6 +395,7 @@ export const fetchArticleThread = (pubkey: string | undefined, noteIds: string,
|
||||
topZaps: {},
|
||||
since: 0,
|
||||
until: 0,
|
||||
wordCount: {},
|
||||
}
|
||||
|
||||
let primaryArticle: PrimalArticle | undefined;
|
||||
|
Loading…
Reference in New Issue
Block a user