+
);
diff --git a/src/components/user/extend.tsx b/src/components/user/extend.tsx
new file mode 100644
index 00000000..c8c7b030
--- /dev/null
+++ b/src/components/user/extend.tsx
@@ -0,0 +1,88 @@
+import { DatabaseContext } from '@components/contexts/database';
+import { ImageWithFallback } from '@components/imageWithFallback';
+
+import { truncate } from '@utils/truncate';
+
+import { DotsHorizontalIcon } from '@radix-ui/react-icons';
+import Avatar from 'boring-avatars';
+import { memo, useCallback, useContext, useEffect, useState } from 'react';
+import Moment from 'react-moment';
+
+export const UserExtend = memo(function UserExtend({ pubkey, time }: { pubkey: string; time: any }) {
+ const { db }: any = useContext(DatabaseContext);
+ const [profile, setProfile] = useState({ picture: null, name: null, username: null });
+
+ const insertCacheProfile = useCallback(
+ async (event) => {
+ const metadata: any = JSON.parse(event.content);
+ // insert to database
+ await db.execute(
+ `INSERT OR IGNORE INTO cache_profiles (id, metadata) VALUES ("${pubkey}", '${JSON.stringify(metadata)}')`
+ );
+ // update state
+ setProfile(metadata);
+ },
+ [db, pubkey]
+ );
+
+ const getCacheProfile = useCallback(async () => {
+ const result: any = await db.select(`SELECT metadata FROM cache_profiles WHERE id = "${pubkey}"`);
+ return result[0];
+ }, [db, pubkey]);
+
+ useEffect(() => {
+ getCacheProfile()
+ .then((res) => {
+ if (res !== undefined) {
+ setProfile(JSON.parse(res.metadata));
+ } else {
+ fetch(`https://rbr.bio/${pubkey}/metadata.json`, { redirect: 'follow' })
+ .then((response) => {
+ if (response.ok) {
+ return response.json();
+ } else if (response.status === 404) {
+ return Promise.reject('error 404');
+ } else {
+ return Promise.reject('some other error: ' + response.status);
+ }
+ })
+ .then((data) => insertCacheProfile(data))
+ .catch((error) => console.log('error is', error));
+ }
+ })
+ .catch(console.error);
+ }, [getCacheProfile, insertCacheProfile, pubkey]);
+
+ return (
+
+
+ {profile.picture ? (
+
+ ) : (
+
+ )}
+
+
+
+
+
+ {profile.name ? profile.name : truncate(pubkey, 16, ' .... ')}
+
+ ยท
+
+ {time}
+
+
+
+
+
+
+
+
+ );
+});
diff --git a/src/pages/newsfeed/following.tsx b/src/pages/newsfeed/following.tsx
index 022b57d7..4fd210b7 100644
--- a/src/pages/newsfeed/following.tsx
+++ b/src/pages/newsfeed/following.tsx
@@ -3,6 +3,7 @@ import WithSidebarLayout from '@layouts/withSidebar';
import { DatabaseContext } from '@components/contexts/database';
import { NoteConnector } from '@components/note/connector';
+import NoteForm from '@components/note/form';
import { Placeholder } from '@components/note/placeholder';
import { Repost } from '@components/note/repost';
import { Single } from '@components/note/single';
@@ -90,7 +91,6 @@ export default function Page() {
return (
-
{hasNewNote && (