replaced moment.js with day.js

This commit is contained in:
Ren Amamiya
2023-03-16 15:23:52 +07:00
parent 9a1ca404c3
commit 096ff38a08
4 changed files with 17 additions and 20 deletions

View File

@@ -5,8 +5,11 @@ import { truncate } from '@utils/truncate';
import { DotsHorizontalIcon } from '@radix-ui/react-icons';
import Avatar from 'boring-avatars';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import { memo, useCallback, useContext, useEffect, useState } from 'react';
import Moment from 'react-moment';
dayjs.extend(relativeTime);
export const UserExtend = memo(function UserExtend({ pubkey, time }: { pubkey: string; time: any }) {
const { db }: any = useContext(DatabaseContext);
@@ -74,9 +77,7 @@ export const UserExtend = memo(function UserExtend({ pubkey, time }: { pubkey: s
{profile.name ? profile.name : truncate(pubkey, 16, ' .... ')}
</span>
<span className="leading-tight text-zinc-500">·</span>
<Moment fromNow unix className="text-zinc-500">
{time}
</Moment>
<span className="text-zinc-500">{dayjs().to(dayjs.unix(time))}</span>
</div>
<div>
<DotsHorizontalIcon className="h-4 w-4 text-zinc-500" />

View File

@@ -48,8 +48,12 @@ export default function Page() {
ORDER BY created_at DESC
LIMIT ${limit.current}`
);
// update data
setData((data) => [...result, ...data]);
// update hasNewerNote to false to disable button
setHasNewerNote(false);
// update current time, fixed duplicate note
now.current = new Date();
}, [db, setHasNewerNote]);
const ItemContent = useCallback(