Show all reads for guests

This commit is contained in:
Bojan Mojsilovic 2024-06-10 14:51:03 +02:00
parent f309b2bfc0
commit 23d8bb980b
5 changed files with 36 additions and 28 deletions

View File

@ -65,24 +65,34 @@ const ReedSelect: Component<{ isPhone?: boolean, id?: string, big?: boolean}> =
}
const options:() => SelectionOption[] = () => {
return [
{
label: 'My Reads',
value: account?.publicKey || '',
},
let opts = [];
if (account?.publicKey) {
opts.push(
{
label: 'My Reads',
value: account?.publicKey || '',
}
);
}
opts.push(
{
label: 'All Reads',
value: 'none',
},
}
);
]
return [ ...opts ];
};
const initialValue = () => {
const selected = reeds?.selectedFeed;
if (!selected) {
return options()[0];
const feed = options()[0];
selectFeed(feed);
return feed;
}
return {

View File

@ -20,7 +20,7 @@ import { createStore } from 'solid-js/store';
import { APP_ID } from '../../App';
import { subsTo } from '../../sockets';
import { getArticleThread, getReadsTopics, getUserArticleFeed } from '../../lib/feed';
import { fetchArticles, fetchUserArticles } from '../../handleNotes';
import { fetchUserArticles } from '../../handleNotes';
import { getParametrizedEvent, getParametrizedEvents } from '../../lib/notes';
import { decodeIdentifier } from '../../lib/keys';
import ArticleShort from '../ArticlePreview/ArticleShort';

View File

@ -164,13 +164,13 @@ const ReadsSidebar: Component< { id?: string } > = (props) => {
});
const getRecomendedArticles = async (ids: string[]) => {
if (!account?.publicKey) return;
// if (!account?.publicKey) return;
const subId = `reads_picks_${APP_ID}`;
setIsFetching(() => true);
const articles = await fetchArticles(account.publicKey, ids,subId);
const articles = await fetchArticles(ids,subId);
setIsFetching(() => false);
@ -180,21 +180,22 @@ const ReadsSidebar: Component< { id?: string } > = (props) => {
return (
<div id={props.id} class={styles.readsSidebar}>
<Show when={account?.isKeyLookupDone}>
<div class={styles.headingPicks}>
Featured Author
</div>
<Show
when={!isFetchingAuthors()}
fallback={
<Loader />
}
>
<div class={styles.section}>
<AuthorSubscribe pubkey={featuredAuthor()} />
<Show when={account?.publicKey}>
<div class={styles.headingPicks}>
Featured Author
</div>
</Show>
<Show
when={!isFetchingAuthors()}
fallback={
<Loader />
}
>
<div class={styles.section}>
<AuthorSubscribe pubkey={featuredAuthor()} />
</div>
</Show>
</Show>
<div class={styles.headingPicks}>
Featured Reads

View File

@ -492,7 +492,6 @@ export const ReadsProvider = (props: { children: ContextChildren }) => {
if (content.kind === Kind.NoteStats) {
const statistic = content as NostrStatsContent;
const stat = JSON.parse(statistic.content);
console.log('READS STATS: ', stat)
if (scope) {
updateStore(scope, 'page', 'postStats',
@ -527,7 +526,6 @@ export const ReadsProvider = (props: { children: ContextChildren }) => {
const noteActionContent = content as NostrNoteActionsContent;
const noteActions = JSON.parse(noteActionContent.content) as NoteActions;
console.log('READS ACTIONS: ', content)
if (scope) {
updateStore(scope, 'page', 'noteActions',
(actions) => ({ ...actions, [noteActions.event_id]: { ...noteActions } })

View File

@ -184,9 +184,8 @@ export const fetchNotes = (pubkey: string | undefined, noteIds: string[], subId:
});
};
export const fetchArticles = (pubkey: string | undefined, noteIds: string[], subId: string) => {
export const fetchArticles = (noteIds: string[], subId: string) => {
return new Promise<PrimalArticle[]>((resolve, reject) => {
if (!pubkey) reject('Missing pubkey');
let page: FeedPage = {
users: {},