added useMetadata and refactor user component

This commit is contained in:
Ren Amamiya
2023-04-06 09:25:18 +07:00
parent 3c63dece46
commit 5437ec5c92
17 changed files with 161 additions and 211 deletions

View File

@@ -54,8 +54,7 @@ export default function Page() {
limit: limit.current,
offset: offset.current,
});
const filteredResult = filteredData(result);
setData((data) => [...data, ...filteredResult]);
setData((data) => [...data, ...result]);
}, []);
const loadMore = useCallback(async () => {
@@ -67,8 +66,7 @@ export default function Page() {
limit: limit.current,
offset: offset.current,
});
const filteredResult = filteredData(result);
setData((data) => [...data, ...filteredResult]);
setData((data) => [...data, ...result]);
}, []);
const loadLatest = useCallback(async () => {
@@ -76,8 +74,7 @@ export default function Page() {
// next query
const result: any = await getLatestNotes({ date: dateToUnix(now.current) });
// update data
const filteredResult = filteredData(result);
setData((data) => [...data, ...filteredResult]);
setData((data) => [...data, ...result]);
// hide newer trigger
setHasNewerNote(false);
// scroll to top
@@ -103,7 +100,7 @@ export default function Page() {
)}
<Virtuoso
ref={virtuosoRef}
data={data}
data={filteredData(data)}
itemContent={itemContent}
computeItemKey={computeItemKey}
components={COMPONENTS}

View File

@@ -85,9 +85,13 @@ export default function Page() {
for (const follow of follows) {
const metadata: any = await fetchMetadata(follow, pool, relays);
createPleb({ pubkey: follow, kind: 0, metadata: metadata.content, account_id: parseInt(id) }).catch(
console.error
);
createPleb({
pleb_id: follow + '-lume' + id,
pubkey: follow,
kind: 0,
metadata: metadata.content,
account_id: parseInt(id),
}).catch(console.error);
}
// build event

View File

@@ -50,9 +50,13 @@ export default function Page() {
if (profile?.id !== null) {
for (const tag of tags) {
const metadata: any = await fetchMetadata(tag[1], pool, relays);
createPleb({ pubkey: tag[1], kind: 0, metadata: metadata.content, account_id: profile.id }).catch(
console.error
);
createPleb({
pleb_id: tag[1] + '-lume' + profile.id.toString(),
pubkey: tag[1],
kind: 0,
metadata: metadata.content,
account_id: profile.id,
}).catch(console.error);
}
}
},