This commit is contained in:
Ren Amamiya
2023-03-22 11:02:56 +07:00
parent ca87624727
commit b687bd9893
3 changed files with 12 additions and 7 deletions

View File

@@ -9,9 +9,6 @@ module.exports = removeImports({
typescript: { typescript: {
ignoreBuildErrors: true, ignoreBuildErrors: true,
}, },
experimental: {
scrollRestoration: true,
},
webpack: (config) => { webpack: (config) => {
config.experiments = { ...config.experiments, topLevelAwait: true }; config.experiments = { ...config.experiments, topLevelAwait: true };
return config; return config;

View File

@@ -2,9 +2,11 @@ import { Content } from '@components/note/content';
import { RootNote } from '@components/note/root'; import { RootNote } from '@components/note/root';
import destr from 'destr'; import destr from 'destr';
import { useRouter } from 'next/router';
import { memo, useMemo } from 'react'; import { memo, useMemo } from 'react';
export const Note = memo(function Note({ event }: { event: any }) { export const Note = memo(function Note({ event }: { event: any }) {
const router = useRouter();
const tags = destr(event.tags); const tags = destr(event.tags);
const fetchRootEvent = useMemo(() => { const fetchRootEvent = useMemo(() => {
@@ -24,8 +26,15 @@ export const Note = memo(function Note({ event }: { event: any }) {
} }
}, [tags]); }, [tags]);
const openThread = () => {
router.push(`/newsfeed/${event.id}`);
};
return ( return (
<div className="relative z-10 flex h-min min-h-min w-full cursor-pointer select-text flex-col border-b border-zinc-800 py-5 px-3 hover:bg-black/20"> <div
onClick={() => openThread()}
className="relative z-10 flex h-min min-h-min w-full cursor-pointer select-text flex-col border-b border-zinc-800 py-5 px-3 hover:bg-black/20"
>
<>{fetchRootEvent}</> <>{fetchRootEvent}</>
<Content data={event} /> <Content data={event} />
</div> </div>

View File

@@ -18,13 +18,12 @@ import {
} from 'react'; } from 'react';
export default function Page() { export default function Page() {
const router = useRouter();
const { db }: any = useContext(DatabaseContext); const { db }: any = useContext(DatabaseContext);
const id = router.query.id;
const [root, setRoot] = useState(null); const [root, setRoot] = useState(null);
const router = useRouter();
const { id }: any = router.query;
const fetchRoot = useCallback(async () => { const fetchRoot = useCallback(async () => {
const result = await db.select(`SELECT * FROM cache_notes WHERE id = "${id}"`); const result = await db.select(`SELECT * FROM cache_notes WHERE id = "${id}"`);
setRoot(result[0]); setRoot(result[0]);