From ff7a75b2ce5f0b339fa92f2646ed2dab548c51be Mon Sep 17 00:00:00 2001
From: Ren Amamiya <123083837+reyamir@users.noreply.github.com>
Date: Thu, 20 Apr 2023 14:14:35 +0700
Subject: [PATCH] minor updates channel
---
src/app/nostr/channels/[id]/page.tsx | 17 +++++++++--------
src/app/page.tsx | 2 +-
.../form/{channelMessage.tsx => channel.tsx} | 12 +++++-------
src/stores/constants.tsx | 4 ++--
4 files changed, 17 insertions(+), 18 deletions(-)
rename src/components/form/{channelMessage.tsx => channel.tsx} (94%)
diff --git a/src/app/nostr/channels/[id]/page.tsx b/src/app/nostr/channels/[id]/page.tsx
index 84d5137b..a25aec1e 100644
--- a/src/app/nostr/channels/[id]/page.tsx
+++ b/src/app/nostr/channels/[id]/page.tsx
@@ -1,16 +1,18 @@
'use client';
import { ChannelMessages } from '@components/channels/messages/index';
-import FormChannelMessage from '@components/form/channelMessage';
+import { FormChannel } from '@components/form/channel';
import { RelayContext } from '@components/relaysProvider';
import { channelMessagesAtom, channelReplyAtom } from '@stores/channel';
import { FULL_RELAYS } from '@stores/constants';
+import { dateToUnix, hoursAgo } from '@utils/getDate';
+
import useLocalStorage from '@rehooks/local-storage';
import { useSetAtom } from 'jotai';
import { useResetAtom } from 'jotai/utils';
-import { Suspense, useContext, useEffect, useRef } from 'react';
+import { useContext, useEffect, useRef } from 'react';
export default function Page({ params }: { params: { id: string } }) {
const [pool]: any = useContext(RelayContext);
@@ -20,6 +22,7 @@ export default function Page({ params }: { params: { id: string } }) {
const resetChannelMessages = useResetAtom(channelMessagesAtom);
const resetChannelReply = useResetAtom(channelReplyAtom);
+ const now = useRef(new Date());
const muted = useRef(new Set());
const hided = useRef(new Set());
@@ -34,12 +37,12 @@ export default function Page({ params }: { params: { id: string } }) {
{
authors: [activeAccount.pubkey],
kinds: [43, 44],
- since: 0,
+ since: dateToUnix(hoursAgo(24, now.current)),
},
{
'#e': [params.id],
kinds: [42],
- since: 0,
+ since: dateToUnix(hoursAgo(24, now.current)),
},
],
FULL_RELAYS,
@@ -67,11 +70,9 @@ export default function Page({ params }: { params: { id: string } }) {
return (
-
Loading...>}>
-
-
+
-
+
);
diff --git a/src/app/page.tsx b/src/app/page.tsx
index f5410845..52aa4101 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -125,7 +125,7 @@ export default function Page() {
undefined,
() => {
updateLastLogin(dateToUnix(now.current));
- //timeout.current = setTimeout(() => router.replace('/nostr/newsfeed/following'), 5000);
+ timeout.current = setTimeout(() => router.replace('/nostr/newsfeed/following'), 5000);
},
{
unsubscribeOnEose: true,
diff --git a/src/components/form/channelMessage.tsx b/src/components/form/channel.tsx
similarity index 94%
rename from src/components/form/channelMessage.tsx
rename to src/components/form/channel.tsx
index f765fdf3..2d0f0c2c 100644
--- a/src/components/form/channelMessage.tsx
+++ b/src/components/form/channel.tsx
@@ -3,6 +3,7 @@ import { RelayContext } from '@components/relaysProvider';
import { UserMini } from '@components/user/mini';
import { channelReplyAtom } from '@stores/channel';
+import { FULL_RELAYS } from '@stores/constants';
import { dateToUnix } from '@utils/getDate';
@@ -13,7 +14,7 @@ import { useResetAtom } from 'jotai/utils';
import { getEventHash, signEvent } from 'nostr-tools';
import { useCallback, useContext, useState } from 'react';
-export default function FormChannelMessage({ eventId }: { eventId: string | string[] }) {
+export const FormChannel = ({ eventId }: { eventId: string | string[] }) => {
const [pool, relays]: any = useContext(RelayContext);
const [value, setValue] = useState('');
@@ -46,7 +47,7 @@ export default function FormChannelMessage({ eventId }: { eventId: string | stri
event.sig = signEvent(event, activeAccount.privkey);
// publish note
- pool.publish(event, relays);
+ pool.publish(event, FULL_RELAYS);
// reset state
setValue('');
// reset channel reply
@@ -110,10 +111,7 @@ export default function FormChannelMessage({ eventId }: { eventId: string | stri
/>
-
+
);
-}
+};
diff --git a/src/stores/constants.tsx b/src/stores/constants.tsx
index dc29a0d3..6f86d0b7 100644
--- a/src/stores/constants.tsx
+++ b/src/stores/constants.tsx
@@ -6,9 +6,9 @@ export const DEFAULT_CHANNELS = [
{
event_id: 'e3cadf5beca1b2af1cddaa41a633679bedf263e3de1eb229c6686c50d85df753',
metadata: {
- name: 'lume-general',
+ name: 'Lume General',
picture: 'https://void.cat/d/UNyxBmAh1MUx5gQTX95jyf.webp',
- about: 'General channel for Lume',
+ about: 'General discussion about the Lume client',
},
created_at: 1681898574,
},