mirror of
https://github.com/PrimalHQ/primal-web-app.git
synced 2024-09-30 00:41:09 +00:00
Show all reads for guests
This commit is contained in:
parent
f309b2bfc0
commit
23d8bb980b
@ -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 {
|
||||
|
@ -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';
|
||||
|
@ -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
|
||||
|
@ -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 } })
|
||||
|
@ -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: {},
|
||||
|
Loading…
Reference in New Issue
Block a user