From 21e0a5b13648ce596dd6d1304ef202a19f7525be Mon Sep 17 00:00:00 2001 From: Yasamato Date: Sat, 30 Dec 2023 14:03:06 +0100 Subject: [PATCH] Add debug, un-hide ping (#89) * Add typecheck against null * Revert "Hide ping till fixed (#79)" This reverts commit f907c7eaef27c35056ff7d4193bb1fa52f8bdfaa. * Update [id].tsx * Update views.ts --- components/data/OnlineStatus.tsx | 4 ++-- lib/db/views.ts | 1 + pages/item/[id].tsx | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/data/OnlineStatus.tsx b/components/data/OnlineStatus.tsx index 628dc8da..4204398a 100644 --- a/components/data/OnlineStatus.tsx +++ b/components/data/OnlineStatus.tsx @@ -47,7 +47,7 @@ const OnlineStatus: FC = ({ item }) => { } return ( -
+ <> setShow(true)} @@ -64,7 +64,7 @@ const OnlineStatus: FC = ({ item }) => { close={() => setShow(false)} /> )} -
+ ) } diff --git a/lib/db/views.ts b/lib/db/views.ts index 8ec28614..48dc658a 100644 --- a/lib/db/views.ts +++ b/lib/db/views.ts @@ -27,6 +27,7 @@ export async function getLastViews(type: Types, n: number) { .limit(n) .toArray() ) + console.log('Found', data.length, 'entries in views table for', type) // count what has been popular recently let accumulated = {} diff --git a/pages/item/[id].tsx b/pages/item/[id].tsx index c54dbd3f..04f8857b 100644 --- a/pages/item/[id].tsx +++ b/pages/item/[id].tsx @@ -27,6 +27,7 @@ import { Column } from '../../types/Column' import { Collection } from '../../types/Collection' import DeleteButton from '../../components/buttons/DeleteButton' import { faStar } from '@fortawesome/free-solid-svg-icons/faStar' +import { findOneTyped, getAllTyped } from '../../lib/db/dbTyped' type Props = { item: Item @@ -359,7 +360,7 @@ const Item: FC = ({ item, columns, collections }) => { export default Item export async function getStaticPaths() { - const items = await getItems() + const items = await getAllTyped(Types.item) const paths = items.map((i) => { return { params: { @@ -375,7 +376,7 @@ export async function getStaticPaths() { } export async function getStaticProps({ params }) { - const item = await getItem(params.id) + const item = await findOneTyped(Types.item, params.id) as Item if (!item) { return { notFound: true,