revert route groups due to nextjs bug, fix build

This commit is contained in:
Ren Amamiya
2023-04-18 07:55:11 +07:00
parent 2b0a4e2402
commit fc258fdcde
38 changed files with 89 additions and 92 deletions

View File

@@ -5,7 +5,7 @@ import { RelayContext } from '@components/relaysProvider';
import { DEFAULT_AVATAR } from '@stores/constants';
import { fetchProfileMetadata } from '@utils/hooks/useProfileMetadata';
import { truncate } from '@utils/truncate';
import { shortenKey } from '@utils/shortenKey';
import Image from 'next/image';
import { useRouter } from 'next/navigation';
@@ -113,9 +113,7 @@ export default function Page({ params }: { params: { privkey: string } }) {
<div className="flex items-center gap-2">
<p className="font-semibold">{profile.metadata?.display_name || profile.metadata?.name}</p>
<span className="leading-tight text-zinc-500">·</span>
<p className="text-zinc-500">
@{profile.metadata?.username || (pubkey && truncate(pubkey, 16, ' .... '))}
</p>
<p className="text-zinc-500">@{profile.metadata?.username || (pubkey && shortenKey(pubkey))}</p>
</div>
<div className="space-y-3">
<div className="grid grid-cols-3 gap-4">

View File

@@ -144,7 +144,7 @@ export default function Page() {
undefined,
() => {
if (eose.current > 5) {
router.replace('/newsfeed/following');
router.replace('/nostr/newsfeed/following');
} else {
eose.current += 1;
}

View File

@@ -1,6 +1,8 @@
'use client';
import RelayProvider from '@components/relaysProvider';
import dynamic from 'next/dynamic';
const RelayProvider = dynamic(() => import('@components/relaysProvider'), { ssr: false });
export function Providers({ children }: { children: React.ReactNode }) {
return <RelayProvider>{children}</RelayProvider>;

View File

@@ -22,7 +22,7 @@ export default function ChannelList() {
return (
<div className="flex flex-col gap-px">
<Link
href="/channels"
href="/nostr/channels"
className="group inline-flex items-center gap-2 rounded-md px-2.5 py-1.5 hover:bg-zinc-900"
>
<div className="inline-flex h-5 w-5 shrink items-center justify-center rounded bg-zinc-900 group-hover:bg-zinc-800">

View File

@@ -8,7 +8,7 @@ export const ChannelListItem = ({ data }: { data: any }) => {
return (
<ActiveLink
href={`/channels/${data.eventId}`}
href={`/nostr/channels/${data.eventId}`}
activeClassName="dark:bg-zinc-900 dark:text-zinc-100 hover:dark:bg-zinc-800"
className="inline-flex items-center gap-2 rounded-md px-2.5 py-1.5 hover:bg-zinc-900"
>

View File

@@ -4,14 +4,14 @@ import { ImageWithFallback } from '@components/imageWithFallback';
import { DEFAULT_AVATAR } from '@stores/constants';
import { useProfileMetadata } from '@utils/hooks/useProfileMetadata';
import { truncate } from '@utils/truncate';
import { shortenKey } from '@utils/shortenKey';
export const ChatListItem = ({ pubkey }: { pubkey: string }) => {
const profile = useProfileMetadata(pubkey);
return (
<ActiveLink
href={`/chats/${pubkey}`}
href={`/nostr/chats/${pubkey}`}
activeClassName="dark:bg-zinc-900 dark:text-zinc-100 hover:dark:bg-zinc-800"
className="inline-flex items-center gap-2 rounded-md px-2.5 py-1.5 hover:bg-zinc-900"
>
@@ -25,7 +25,7 @@ export const ChatListItem = ({ pubkey }: { pubkey: string }) => {
</div>
<div>
<h5 className="text-sm font-medium text-zinc-400">
{profile?.display_name || profile?.name || truncate(pubkey, 16, ' .... ')}
{profile?.display_name || profile?.name || shortenKey(pubkey)}
</h5>
</div>
</ActiveLink>

View File

@@ -2,7 +2,7 @@ import { ImageWithFallback } from '@components/imageWithFallback';
import { DEFAULT_AVATAR } from '@stores/constants';
import { truncate } from '@utils/truncate';
import { shortenKey } from '@utils/shortenKey';
import { useRouter } from 'next/navigation';
@@ -29,7 +29,7 @@ export const ChatModalUser = ({ data }: { data: any }) => {
<span className="truncate text-sm font-semibold leading-tight text-zinc-200">
{profile?.display_name || profile?.name}
</span>
<span className="text-sm leading-tight text-zinc-400">{truncate(data.pubkey, 16, ' .... ')}</span>
<span className="text-sm leading-tight text-zinc-400">{shortenKey(data.pubkey)}</span>
</div>
</div>
<div>

View File

@@ -3,7 +3,7 @@ import { ImageWithFallback } from '@components/imageWithFallback';
import { DEFAULT_AVATAR } from '@stores/constants';
import { useProfileMetadata } from '@utils/hooks/useProfileMetadata';
import { truncate } from '@utils/truncate';
import { shortenKey } from '@utils/shortenKey';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
@@ -26,7 +26,7 @@ export const MessageUser = ({ pubkey, time }: { pubkey: string; time: number })
<div className="flex w-full flex-1 items-start justify-between">
<div className="flex items-baseline gap-2 text-sm">
<span className="font-semibold leading-none text-zinc-200 group-hover:underline">
{profile?.display_name || profile?.name || truncate(pubkey, 16, ' .... ')}
{profile?.display_name || profile?.name || shortenKey(pubkey)}
</span>
<span className="leading-none text-zinc-500">·</span>
<span className="leading-none text-zinc-500">{dayjs().to(dayjs.unix(time))}</span>

View File

@@ -14,7 +14,7 @@ export const ActiveAccount = ({ user }: { user: any }) => {
const userData = JSON.parse(user.metadata);
const openProfilePage = () => {
router.push(`/users/${user.pubkey}`);
router.push(`/nostr/users/${user.pubkey}`);
};
const copyPublicKey = async () => {

View File

@@ -24,7 +24,7 @@ export default function Newsfeed() {
</Collapsible.Trigger>
<Collapsible.Content className="flex flex-col text-zinc-400">
<ActiveLink
href="/newsfeed/following"
href="/nostr/newsfeed/following"
activeClassName="dark:bg-zinc-900 dark:text-zinc-100 hover:dark:bg-zinc-800"
className="flex h-8 items-center gap-2.5 rounded-md px-2.5 text-sm font-medium hover:text-zinc-200"
>
@@ -32,7 +32,7 @@ export default function Newsfeed() {
<span>Following</span>
</ActiveLink>
<ActiveLink
href="/newsfeed/circle"
href="/nostr/newsfeed/circle"
activeClassName="dark:bg-zinc-900 dark:text-zinc-100 hover:dark:bg-zinc-800"
className="flex h-8 items-center gap-2.5 rounded-md px-2.5 text-sm font-medium hover:text-zinc-200"
>

View File

@@ -22,7 +22,7 @@ export const NoteBase = memo(function NoteBase({ event }: { event: any }) {
const openUserPage = (e) => {
e.stopPropagation();
router.push(`/users/${event.pubkey}`);
router.push(`/nostr/users/${event.pubkey}`);
};
const openThread = (e) => {

View File

@@ -34,7 +34,7 @@ export const NoteComment = ({
const profile = activeAccount.metadata ? JSON.parse(activeAccount.metadata) : null;
const openThread = () => {
router.push(`/newsfeed/${eventID}`);
router.push(`/nostr/newsfeed/${eventID}`);
};
const submitEvent = () => {

View File

@@ -18,13 +18,13 @@ export const RootNote = memo(function RootNote({ event }: { event: any }) {
const openUserPage = (e) => {
e.stopPropagation();
router.push(`/users/${event.pubkey}`);
router.push(`/nostr/users/${event.pubkey}`);
};
const openThread = (e) => {
const selection = window.getSelection();
if (selection.toString().length === 0) {
router.push(`/newsfeed/${event.id}`);
router.push(`/nostr/newsfeed/${event.id}`);
} else {
e.stopPropagation();
}

View File

@@ -5,7 +5,7 @@ import { RelayContext } from '@components/relaysProvider';
import { DEFAULT_AVATAR } from '@stores/constants';
import { truncate } from '@utils/truncate';
import { shortenKey } from '@utils/shortenKey';
import destr from 'destr';
import Image from 'next/image';
@@ -51,9 +51,7 @@ export default function ProfileMetadata({ id }: { id: string }) {
<h3 className="text-lg font-semibold leading-tight text-zinc-100">
{profile?.display_name || profile?.name}
</h3>
<span className="text-sm leading-tight text-zinc-500">
{profile?.username || (id && truncate(id, 16, ' .... '))}
</span>
<span className="text-sm leading-tight text-zinc-500">{profile?.username || (id && shortenKey(id))}</span>
</div>
<div className="prose-sm prose-zinc leading-tight dark:prose-invert">{profile?.about}</div>
</div>

View File

@@ -3,7 +3,7 @@ import { ImageWithFallback } from '@components/imageWithFallback';
import { DEFAULT_AVATAR } from '@stores/constants';
import { useProfileMetadata } from '@utils/hooks/useProfileMetadata';
import { truncate } from '@utils/truncate';
import { shortenKey } from '@utils/shortenKey';
import { memo } from 'react';
@@ -24,7 +24,7 @@ export const UserBase = memo(function UserBase({ pubkey }: { pubkey: string }) {
<span className="truncate font-medium leading-tight text-zinc-200">
{profile?.display_name || profile?.name}
</span>
<span className="text-sm leading-tight text-zinc-400">{truncate(pubkey, 16, ' .... ')}</span>
<span className="text-sm leading-tight text-zinc-400">{shortenKey(pubkey)}</span>
</div>
</div>
);

View File

@@ -3,7 +3,7 @@ import { ImageWithFallback } from '@components/imageWithFallback';
import { DEFAULT_AVATAR } from '@stores/constants';
import { useProfileMetadata } from '@utils/hooks/useProfileMetadata';
import { truncate } from '@utils/truncate';
import { shortenKey } from '@utils/shortenKey';
export const UserFollow = ({ pubkey }: { pubkey: string }) => {
const profile = useProfileMetadata(pubkey);
@@ -22,7 +22,7 @@ export const UserFollow = ({ pubkey }: { pubkey: string }) => {
<span className="truncate font-medium leading-tight text-zinc-200">
{profile?.display_name || profile?.name}
</span>
<span className="text-sm leading-tight text-zinc-400">{truncate(pubkey, 16, ' .... ')}</span>
<span className="text-sm leading-tight text-zinc-400">{shortenKey(pubkey)}</span>
</div>
</div>
);

View File

@@ -3,7 +3,7 @@ import { ImageWithFallback } from '@components/imageWithFallback';
import { DEFAULT_AVATAR } from '@stores/constants';
import { useProfileMetadata } from '@utils/hooks/useProfileMetadata';
import { truncate } from '@utils/truncate';
import { shortenKey } from '@utils/shortenKey';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
@@ -28,10 +28,10 @@ export const UserLarge = ({ pubkey, time }: { pubkey: string; time: number }) =>
<div className="flex w-full justify-between">
<div className="flex flex-col gap-1 text-sm">
<span className="font-bold leading-tight text-zinc-100">
{profile?.display_name || profile?.name || truncate(pubkey, 16, ' .... ')}
{profile?.display_name || profile?.name || shortenKey(pubkey)}
</span>
<span className="leading-tight text-zinc-400">
{profile?.username || truncate(pubkey, 16, ' .... ')} · {dayjs().to(dayjs.unix(time))}
{profile?.username || shortenKey(pubkey)} · {dayjs().to(dayjs.unix(time))}
</span>
</div>
<div>

View File

@@ -1,11 +1,9 @@
import { useProfileMetadata } from '@utils/hooks/useProfileMetadata';
import { truncate } from '@utils/truncate';
import { shortenKey } from '@utils/shortenKey';
export const UserMention = ({ pubkey }: { pubkey: string }) => {
const profile = useProfileMetadata(pubkey);
return (
<span className="cursor-pointer text-fuchsia-500">
@{profile?.name || profile?.username || truncate(pubkey, 16, ' .... ')}
</span>
<span className="cursor-pointer text-fuchsia-500">@{profile?.name || profile?.username || shortenKey(pubkey)}</span>
);
};

View File

@@ -3,7 +3,7 @@ import { ImageWithFallback } from '@components/imageWithFallback';
import { DEFAULT_AVATAR } from '@stores/constants';
import { useProfileMetadata } from '@utils/hooks/useProfileMetadata';
import { truncate } from '@utils/truncate';
import { shortenKey } from '@utils/shortenKey';
export const UserMini = ({ pubkey }: { pubkey: string }) => {
const profile = useProfileMetadata(pubkey);
@@ -19,7 +19,7 @@ export const UserMini = ({ pubkey }: { pubkey: string }) => {
/>
</div>
<span className="text-xs font-medium leading-none text-zinc-500">
Replying to {profile?.name || truncate(pubkey, 16, ' .... ')}
Replying to {profile?.name || shortenKey(pubkey)}
</span>
</div>
);

View File

@@ -3,7 +3,7 @@ import { ImageWithFallback } from '@components/imageWithFallback';
import { DEFAULT_AVATAR } from '@stores/constants';
import { useProfileMetadata } from '@utils/hooks/useProfileMetadata';
import { truncate } from '@utils/truncate';
import { shortenKey } from '@utils/shortenKey';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
@@ -25,7 +25,7 @@ export const UserQuoteRepost = ({ pubkey, time }: { pubkey: string; time: number
</div>
<div className="flex items-baseline gap-2 text-sm">
<h5 className="font-bold leading-tight group-hover:underline">
{profile?.display_name || profile?.name || truncate(pubkey, 16, ' .... ')} reposted
{profile?.display_name || profile?.name || shortenKey(pubkey)} reposted
</h5>
<span className="leading-tight text-zinc-500">·</span>
<span className="text-zinc-500">{dayjs().to(dayjs.unix(time))}</span>

View File

@@ -68,6 +68,7 @@ export function getChats(data: GetChatData) {
return invoke<Chat[]>('get_chats', { data });
}
export type GetLatestNoteData = { date: number };
export type Note = {
id: number;
eventId: string;
@@ -80,17 +81,8 @@ export type Note = {
createdAt: number;
accountId: number;
};
export type GetActiveChannelData = { active: boolean };
export type CreateChannelData = { event_id: string; content: string; account_id: number };
export type CreatePlebData = { pleb_id: string; pubkey: string; kind: number; metadata: string; account_id: number };
export type Chat = { id: number; pubkey: string; createdAt: number; accountId: number };
export type Account = { id: number; pubkey: string; privkey: string; active: boolean; metadata: string };
export type GetChannelData = { limit: number; offset: number };
export type GetLatestNoteData = { date: number };
export type GetPlebData = { account_id: number; kind: number };
export type CreateAccountData = { pubkey: string; privkey: string; metadata: string };
export type GetPlebPubkeyData = { pubkey: string };
export type Channel = { id: number; eventId: string; content: string; active: boolean; accountId: number };
export type GetChatData = { account_id: number };
export type CreateNoteData = {
event_id: string;
pubkey: string;
@@ -102,9 +94,17 @@ export type CreateNoteData = {
created_at: number;
account_id: number;
};
export type UpdateChannelData = { event_id: string; active: boolean };
export type Pleb = { id: number; plebId: string; pubkey: string; kind: number; metadata: string; accountId: number };
export type CreateChatData = { pubkey: string; created_at: number; account_id: number };
export type GetNoteData = { date: number; limit: number; offset: number };
export type GetActiveChannelData = { active: boolean };
export type GetPlebData = { account_id: number; kind: number };
export type CreatePlebData = { pleb_id: string; pubkey: string; kind: number; metadata: string; account_id: number };
export type Chat = { id: number; pubkey: string; createdAt: number; accountId: number };
export type Account = { id: number; pubkey: string; privkey: string; active: boolean; metadata: string };
export type GetNoteByIdData = { event_id: string };
export type GetPlebPubkeyData = { pubkey: string };
export type GetChatData = { account_id: number };
export type GetNoteData = { date: number; limit: number; offset: number };
export type Channel = { id: number; eventId: string; content: string; active: boolean; accountId: number };
export type UpdateChannelData = { event_id: string; active: boolean };
export type CreateChatData = { pubkey: string; created_at: number; account_id: number };
export type CreateAccountData = { pubkey: string; privkey: string; metadata: string };
export type GetChannelData = { limit: number; offset: number };
export type Pleb = { id: number; plebId: string; pubkey: string; kind: number; metadata: string; accountId: number };