note tab
This commit is contained in:
@@ -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 = `
|
||||
<a href="/" class="tab">/</a>
|
||||
<a href="/@${handle}" class="tab ${activeTab === 'blog' ? 'active' : ''}">${handle}</a>
|
||||
@@ -33,8 +33,8 @@ export function renderModeTabs(handle: string, activeTab: 'blog' | 'browser' | '
|
||||
tabs += `<a href="/@${handle}/at/chat" class="tab ${activeTab === 'chat' ? 'active' : ''}">chat</a>`
|
||||
}
|
||||
|
||||
// Note tab only for local user (admin)
|
||||
if (isLocalUser) {
|
||||
// Note tab only for local user (admin) with note posts
|
||||
if (isLocalUser && hasNotes) {
|
||||
tabs += `<a href="/@${handle}/at/note" class="tab ${activeTab === 'note' ? 'active' : ''}">note</a>`
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +188,9 @@ async function render(route: Route): Promise<void> {
|
||||
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<void> {
|
||||
html += `<nav class="back-nav"><a href="/@${handle}">${handle}</a></nav>`
|
||||
|
||||
} 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 += `<div id="content">${renderNoteListPage(notePosts, handle)}</div>`
|
||||
html += `<nav class="back-nav"><a href="/@${handle}">${handle}</a></nav>`
|
||||
|
||||
} 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 += `<div id="content">${renderNoteDetailPage(notePost, handle, localOnly)}</div>`
|
||||
@@ -486,7 +485,6 @@ async function render(route: Route): Promise<void> {
|
||||
|
||||
// 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)
|
||||
|
||||
Reference in New Issue
Block a user