From 730f3be01666f7461fe6748aee17319c247fc6e0 Mon Sep 17 00:00:00 2001 From: Ren Amamiya <123083837+reyamir@users.noreply.github.com> Date: Sun, 7 May 2023 11:13:46 +0700 Subject: [PATCH] add kind 30023 to initial data --- src/app/inital-data/pages/index.page.tsx | 46 +++++++++++++++++++++--- src/app/note/components/user/default.tsx | 3 +- src/app/note/components/user/repost.tsx | 5 +-- src/utils/storage.tsx | 26 ++++++++++++-- 4 files changed, 70 insertions(+), 10 deletions(-) diff --git a/src/app/inital-data/pages/index.page.tsx b/src/app/inital-data/pages/index.page.tsx index d401bd22..98f71802 100644 --- a/src/app/inital-data/pages/index.page.tsx +++ b/src/app/inital-data/pages/index.page.tsx @@ -4,6 +4,7 @@ import { READONLY_RELAYS } from '@lume/stores/constants'; import { dateToUnix, hoursAgo } from '@lume/utils/getDate'; import { addToBlacklist, + countTotalLongNotes, countTotalNotes, createChat, createNote, @@ -28,19 +29,31 @@ export function Page() { const account = await getActiveAccount(); const lastLogin = await getLastLogin(); const notes = await countTotalNotes(); + const longNotes = await countTotalLongNotes(); const follows = nip02ToArray(JSON.parse(account.follows)); const query = []; - let since: number; + let sinceNotes: number; + let sinceLongNotes: number; if (notes === 0) { - since = dateToUnix(hoursAgo(24, now.current)); + sinceNotes = dateToUnix(hoursAgo(48, now.current)); } else { if (parseInt(lastLogin) > 0) { - since = parseInt(lastLogin); + sinceNotes = parseInt(lastLogin); } else { - since = dateToUnix(hoursAgo(24, now.current)); + sinceNotes = dateToUnix(hoursAgo(48, now.current)); + } + } + + if (longNotes === 0) { + sinceLongNotes = 0; + } else { + if (parseInt(lastLogin) > 0) { + sinceLongNotes = parseInt(lastLogin); + } else { + sinceLongNotes = 0; } } @@ -48,7 +61,7 @@ export function Page() { query.push({ kinds: [1, 6], authors: follows, - since: since, + since: sinceNotes, until: dateToUnix(now.current), }); @@ -68,6 +81,13 @@ export function Page() { until: dateToUnix(now.current), }); + // kind 30023 (long post) query + query.push({ + kinds: [30023], + since: sinceLongNotes, + until: dateToUnix(now.current), + }); + // subscribe relays unsubscribe = pool.subscribe( query, @@ -113,11 +133,27 @@ export function Page() { if (event.tags[0][0] === 'e') { addToBlacklist(account.id, event.tags[0][1], 43, 1); } + break; // mute user (channel only) case 44: if (event.tags[0][0] === 'p') { addToBlacklist(account.id, event.tags[0][1], 44, 1); } + break; + // long post + case 30023: + // insert event to local database + createNote( + event.id, + account.id, + event.pubkey, + event.kind, + event.tags, + event.content, + event.created_at, + '' + ); + break; default: break; } diff --git a/src/app/note/components/user/default.tsx b/src/app/note/components/user/default.tsx index fea5523d..167b6711 100644 --- a/src/app/note/components/user/default.tsx +++ b/src/app/note/components/user/default.tsx @@ -5,6 +5,7 @@ import { shortenKey } from '@lume/utils/shortenKey'; import dayjs from 'dayjs'; import relativeTime from 'dayjs/plugin/relativeTime'; +import Skeleton from 'react-loading-skeleton'; dayjs.extend(relativeTime); @@ -24,7 +25,7 @@ export const NoteDefaultUser = ({ pubkey, time }: { pubkey: string; time: number