diff --git a/locales/en/translation.json b/locales/en/translation.json index 098bbbad..430ab79a 100644 --- a/locales/en/translation.json +++ b/locales/en/translation.json @@ -4,6 +4,7 @@ "notifications": "Notifications", "local": "Local", "public": "Public", + "bookmarks": "Bookmarks", "search": "Search", "status": { "avatar": "Aavtar of {user}", diff --git a/renderer/components/Jump.tsx b/renderer/components/Jump.tsx index 07a06d66..ba012ca9 100644 --- a/renderer/components/Jump.tsx +++ b/renderer/components/Jump.tsx @@ -2,15 +2,12 @@ import { Dialog, DialogBody, Input, List, ListItem } from '@material-tailwind/re import { useRouter } from 'next/router' import { useCallback, useEffect, useRef, useState } from 'react' import { useIntl } from 'react-intl' +import { Timeline } from './layouts/timelines' type Props = { opened: boolean close: () => void -} - -type Timeline = { - title: string - path: string + timelines: Array } export default function Jump(props: Props) { @@ -65,13 +62,8 @@ export default function Jump(props: Props) { }, [keyword, timelines]) useEffect(() => { - setTimelines([ - { title: formatMessage({ id: 'timeline.home' }), path: `/accounts/${router.query.id}/home` }, - { title: formatMessage({ id: 'timeline.notifications' }), path: `/accounts/${router.query.id}/notifications` }, - { title: formatMessage({ id: 'timeline.local' }), path: `/accounts/${router.query.id}/local` }, - { title: formatMessage({ id: 'timeline.public' }), path: `/accounts/${router.query.id}/public` } - ]) - }, [router.query.id]) + setTimelines(props.timelines) + }, [router.query.id, props.timelines]) const jump = (path: string) => { props.close() diff --git a/renderer/components/layouts/timelines.tsx b/renderer/components/layouts/timelines.tsx index 6cf012b2..bbb5246d 100644 --- a/renderer/components/layouts/timelines.tsx +++ b/renderer/components/layouts/timelines.tsx @@ -4,7 +4,7 @@ import generator, { Entity } from 'megalodon' import { useRouter } from 'next/router' import { useEffect, useState } from 'react' import { useHotkeys } from 'react-hotkeys-hook' -import { FaBell, FaGlobe, FaHouse, FaList, FaUsers } from 'react-icons/fa6' +import { FaBell, FaBookmark, FaGlobe, FaHouse, FaList, FaUsers } from 'react-icons/fa6' import { useIntl } from 'react-intl' import Jump from '../Jump' import { useUnreads } from '@/provider/unreads' @@ -13,6 +13,13 @@ type LayoutProps = { children: React.ReactNode } +export type Timeline = { + id: string + title: string + icon: JSX.Element + path: string +} + export default function Layout({ children }: LayoutProps) { const router = useRouter() const { formatMessage } = useIntl() @@ -45,7 +52,7 @@ export default function Layout({ children }: LayoutProps) { f() }, [account]) - const pages = [ + const pages: Array = [ { id: 'home', title: formatMessage({ id: 'timeline.home' }), @@ -69,12 +76,18 @@ export default function Layout({ children }: LayoutProps) { title: formatMessage({ id: 'timeline.public' }), icon: , path: `/accounts/${router.query.id}/public` + }, + { + id: 'bookmarks', + title: formatMessage({ id: 'timeline.bookmarks' }), + icon: , + path: `/accounts/${router.query.id}/bookmarks` } ] return (
- setOpenJump(false)} /> + setOpenJump(false)} timelines={pages} />

{account?.username}

diff --git a/renderer/components/timelines/Timeline.tsx b/renderer/components/timelines/Timeline.tsx index 676a3b94..2086d6f7 100644 --- a/renderer/components/timelines/Timeline.tsx +++ b/renderer/components/timelines/Timeline.tsx @@ -73,7 +73,7 @@ export default function Timeline(props: Props) { } default: { const match = props.timeline.match(/list_(\d+)/) - if (match[1] && typeof match[1] === 'string') { + if (match && match[1] && typeof match[1] === 'string') { const res = await props.client.getList(match[1]) streaming.current = c.listSocket(match[1]) setList(res.data) @@ -145,6 +145,10 @@ export default function Timeline(props: Props) { const res = await client.getPublicTimeline(options) return res.data } + case 'bookmarks': { + const res = await client.getBookmarks(options) + return res.data + } default: { // Check list const match = tl.match(/list_(\d+)/)