minor updates channel
This commit is contained in:
@@ -1,16 +1,18 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { ChannelMessages } from '@components/channels/messages/index';
|
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 { RelayContext } from '@components/relaysProvider';
|
||||||
|
|
||||||
import { channelMessagesAtom, channelReplyAtom } from '@stores/channel';
|
import { channelMessagesAtom, channelReplyAtom } from '@stores/channel';
|
||||||
import { FULL_RELAYS } from '@stores/constants';
|
import { FULL_RELAYS } from '@stores/constants';
|
||||||
|
|
||||||
|
import { dateToUnix, hoursAgo } from '@utils/getDate';
|
||||||
|
|
||||||
import useLocalStorage from '@rehooks/local-storage';
|
import useLocalStorage from '@rehooks/local-storage';
|
||||||
import { useSetAtom } from 'jotai';
|
import { useSetAtom } from 'jotai';
|
||||||
import { useResetAtom } from 'jotai/utils';
|
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 } }) {
|
export default function Page({ params }: { params: { id: string } }) {
|
||||||
const [pool]: any = useContext(RelayContext);
|
const [pool]: any = useContext(RelayContext);
|
||||||
@@ -20,6 +22,7 @@ export default function Page({ params }: { params: { id: string } }) {
|
|||||||
const resetChannelMessages = useResetAtom(channelMessagesAtom);
|
const resetChannelMessages = useResetAtom(channelMessagesAtom);
|
||||||
const resetChannelReply = useResetAtom(channelReplyAtom);
|
const resetChannelReply = useResetAtom(channelReplyAtom);
|
||||||
|
|
||||||
|
const now = useRef(new Date());
|
||||||
const muted = useRef(new Set());
|
const muted = useRef(new Set());
|
||||||
const hided = useRef(new Set());
|
const hided = useRef(new Set());
|
||||||
|
|
||||||
@@ -34,12 +37,12 @@ export default function Page({ params }: { params: { id: string } }) {
|
|||||||
{
|
{
|
||||||
authors: [activeAccount.pubkey],
|
authors: [activeAccount.pubkey],
|
||||||
kinds: [43, 44],
|
kinds: [43, 44],
|
||||||
since: 0,
|
since: dateToUnix(hoursAgo(24, now.current)),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'#e': [params.id],
|
'#e': [params.id],
|
||||||
kinds: [42],
|
kinds: [42],
|
||||||
since: 0,
|
since: dateToUnix(hoursAgo(24, now.current)),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
FULL_RELAYS,
|
FULL_RELAYS,
|
||||||
@@ -67,11 +70,9 @@ export default function Page({ params }: { params: { id: string } }) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full w-full flex-col justify-between">
|
<div className="flex h-full w-full flex-col justify-between">
|
||||||
<Suspense fallback={<>Loading...</>}>
|
|
||||||
<ChannelMessages />
|
<ChannelMessages />
|
||||||
</Suspense>
|
|
||||||
<div className="shrink-0 p-3">
|
<div className="shrink-0 p-3">
|
||||||
<FormChannelMessage eventId={params.id} />
|
<FormChannel eventId={params.id} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ export default function Page() {
|
|||||||
undefined,
|
undefined,
|
||||||
() => {
|
() => {
|
||||||
updateLastLogin(dateToUnix(now.current));
|
updateLastLogin(dateToUnix(now.current));
|
||||||
//timeout.current = setTimeout(() => router.replace('/nostr/newsfeed/following'), 5000);
|
timeout.current = setTimeout(() => router.replace('/nostr/newsfeed/following'), 5000);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
unsubscribeOnEose: true,
|
unsubscribeOnEose: true,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { RelayContext } from '@components/relaysProvider';
|
|||||||
import { UserMini } from '@components/user/mini';
|
import { UserMini } from '@components/user/mini';
|
||||||
|
|
||||||
import { channelReplyAtom } from '@stores/channel';
|
import { channelReplyAtom } from '@stores/channel';
|
||||||
|
import { FULL_RELAYS } from '@stores/constants';
|
||||||
|
|
||||||
import { dateToUnix } from '@utils/getDate';
|
import { dateToUnix } from '@utils/getDate';
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ import { useResetAtom } from 'jotai/utils';
|
|||||||
import { getEventHash, signEvent } from 'nostr-tools';
|
import { getEventHash, signEvent } from 'nostr-tools';
|
||||||
import { useCallback, useContext, useState } from 'react';
|
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 [pool, relays]: any = useContext(RelayContext);
|
||||||
|
|
||||||
const [value, setValue] = useState('');
|
const [value, setValue] = useState('');
|
||||||
@@ -46,7 +47,7 @@ export default function FormChannelMessage({ eventId }: { eventId: string | stri
|
|||||||
event.sig = signEvent(event, activeAccount.privkey);
|
event.sig = signEvent(event, activeAccount.privkey);
|
||||||
|
|
||||||
// publish note
|
// publish note
|
||||||
pool.publish(event, relays);
|
pool.publish(event, FULL_RELAYS);
|
||||||
// reset state
|
// reset state
|
||||||
setValue('');
|
setValue('');
|
||||||
// reset channel reply
|
// reset channel reply
|
||||||
@@ -110,10 +111,7 @@ export default function FormChannelMessage({ eventId }: { eventId: string | stri
|
|||||||
/>
|
/>
|
||||||
<div className="absolute bottom-2 w-full px-2">
|
<div className="absolute bottom-2 w-full px-2">
|
||||||
<div className="flex w-full items-center justify-between bg-zinc-800">
|
<div className="flex w-full items-center justify-between bg-zinc-800">
|
||||||
<div className="flex items-center gap-2 divide-x divide-zinc-700">
|
<div className="flex items-center gap-2 divide-x divide-zinc-700"></div>
|
||||||
<ImagePicker />
|
|
||||||
<div className="flex items-center gap-2 pl-2"></div>
|
|
||||||
</div>
|
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<button
|
<button
|
||||||
onClick={() => submitEvent()}
|
onClick={() => submitEvent()}
|
||||||
@@ -127,4 +125,4 @@ export default function FormChannelMessage({ eventId }: { eventId: string | stri
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
@@ -6,9 +6,9 @@ export const DEFAULT_CHANNELS = [
|
|||||||
{
|
{
|
||||||
event_id: 'e3cadf5beca1b2af1cddaa41a633679bedf263e3de1eb229c6686c50d85df753',
|
event_id: 'e3cadf5beca1b2af1cddaa41a633679bedf263e3de1eb229c6686c50d85df753',
|
||||||
metadata: {
|
metadata: {
|
||||||
name: 'lume-general',
|
name: 'Lume General',
|
||||||
picture: 'https://void.cat/d/UNyxBmAh1MUx5gQTX95jyf.webp',
|
picture: 'https://void.cat/d/UNyxBmAh1MUx5gQTX95jyf.webp',
|
||||||
about: 'General channel for Lume',
|
about: 'General discussion about the Lume client',
|
||||||
},
|
},
|
||||||
created_at: 1681898574,
|
created_at: 1681898574,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user