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