When 100+ future notes are available do not reload

This commit is contained in:
Bojan Mojsilovic 2024-03-18 15:09:10 +01:00
parent f07932707d
commit e287eac150
2 changed files with 11 additions and 1 deletions

View File

@ -64,6 +64,7 @@ type HomeContextStore = {
loadFutureContent: () => void, loadFutureContent: () => void,
doSidebarSearch: (query: string) => void, doSidebarSearch: (query: string) => void,
updateSidebarQuery: (selection: SelectionOption) => void, updateSidebarQuery: (selection: SelectionOption) => void,
getFirstPage: () => void,
} }
} }
@ -387,6 +388,14 @@ export const HomeProvider = (props: { children: ContextChildren }) => {
} }
}; };
const getFirstPage = () => {
const feed = store.selectedFeed;
if (!feed?.hex) return;
clearNotes();
fetchNotes(feed.hex , `${APP_ID}`, 0, feed.includeReplies);
};
const updatePage = (content: NostrEventContent, scope?: 'future') => { const updatePage = (content: NostrEventContent, scope?: 'future') => {
if (content.kind === Kind.Metadata) { if (content.kind === Kind.Metadata) {
const user = content as NostrUserContent; const user = content as NostrUserContent;
@ -698,6 +707,7 @@ export const HomeProvider = (props: { children: ContextChildren }) => {
loadFutureContent, loadFutureContent,
doSidebarSearch, doSidebarSearch,
updateSidebarQuery, updateSidebarQuery,
getFirstPage,
}, },
}); });

View File

@ -111,7 +111,7 @@ const Home: Component = () => {
const loadNewContent = () => { const loadNewContent = () => {
if (newNotesCount() > 100 || app?.appState === 'waking') { if (newNotesCount() > 100 || app?.appState === 'waking') {
location.reload(); context?.actions.getFirstPage();
return; return;
} }