diff --git a/src/web/components/mode-tabs.ts b/src/web/components/mode-tabs.ts index fd9f56c..29a84f5 100644 --- a/src/web/components/mode-tabs.ts +++ b/src/web/components/mode-tabs.ts @@ -21,7 +21,7 @@ export function setCurrentLang(lang: string): void { localStorage.setItem('preferred-lang', lang) } -export function renderModeTabs(handle: string, activeTab: 'blog' | 'browser' | 'post' | 'chat' | 'link' | 'note' = 'blog', isLocalUser: boolean = false): string { +export function renderModeTabs(handle: string, activeTab: 'blog' | 'browser' | 'post' | 'chat' | 'link' | 'note' = 'blog', isLocalUser: boolean = false, hasNotes: boolean = false): string { let tabs = ` / ${handle} @@ -33,8 +33,8 @@ export function renderModeTabs(handle: string, activeTab: 'blog' | 'browser' | ' tabs += `chat` } - // Note tab only for local user (admin) - if (isLocalUser) { + // Note tab only for local user (admin) with note posts + if (isLocalUser && hasNotes) { tabs += `note` } diff --git a/src/web/main.ts b/src/web/main.ts index e63196b..3d3809c 100644 --- a/src/web/main.ts +++ b/src/web/main.ts @@ -188,7 +188,9 @@ async function render(route: Route): Promise { route.type === 'link' ? 'link' : (route.type === 'note' || route.type === 'note-detail') ? 'note' : (route.type === 'atbrowser' || route.type === 'service' || route.type === 'collection' || route.type === 'record' ? 'browser' : 'blog') - html += renderModeTabs(handle, activeTab, localOnly) + const noteCollection = 'ai.syui.note.post' + const notePosts = localOnly ? await getPosts(did, noteCollection, true) : [] + html += renderModeTabs(handle, activeTab, localOnly, notePosts.length > 0) // Check if logged-in user owns this content const loggedInDid = getLoggedInDid() @@ -293,15 +295,12 @@ async function render(route: Route): Promise { html += `` } else if (route.type === 'note') { - // Note list page - const noteCollection = 'ai.syui.note.post' - const notePosts = await getPosts(did, noteCollection, localOnly) + // Note list page (reuse notePosts from above) html += `
${renderNoteListPage(notePosts, handle)}
` html += `` } else if (route.type === 'note-detail' && route.rkey) { // Note detail page - const noteCollection = 'ai.syui.note.post' const notePost = await getPost(did, noteCollection, route.rkey, localOnly) if (notePost) { html += `
${renderNoteDetailPage(notePost, handle, localOnly)}
` @@ -486,7 +485,6 @@ async function render(route: Route): Promise { // Setup note detail page if (route.type === 'note-detail' && route.rkey) { - const noteCollection = 'ai.syui.note.post' const notePost = await getPost(did, noteCollection, route.rkey, localOnly) if (notePost && localOnly) { setupNoteDetail(notePost)