mirror of
https://github.com/smolgrrr/TAO.git
synced 2024-09-20 09:21:25 +00:00
UI work
This commit is contained in:
parent
5404ad0bf9
commit
316c31206e
@ -1,8 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
ArrowUpTrayIcon,
|
ServerIcon,
|
||||||
CpuChipIcon,
|
CpuChipIcon,
|
||||||
ArrowPathIcon,
|
ArrowPathIcon,
|
||||||
FaceSmileIcon
|
PlusCircleIcon
|
||||||
} from "@heroicons/react/24/outline";
|
} from "@heroicons/react/24/outline";
|
||||||
import { XCircleIcon } from "@heroicons/react/24/solid";
|
import { XCircleIcon } from "@heroicons/react/24/solid";
|
||||||
import { useState, useEffect, useRef } from "react";
|
import { useState, useEffect, useRef } from "react";
|
||||||
@ -135,13 +135,13 @@ const NewNoteCard = ({
|
|||||||
>
|
>
|
||||||
<input type="hidden" name="MAX_FILE_SIZE" defaultValue={2.5 * 1024 * 1024} />
|
<input type="hidden" name="MAX_FILE_SIZE" defaultValue={2.5 * 1024 * 1024} />
|
||||||
<div className="px-4 flex flex-col rounded-lg">
|
<div className="px-4 flex flex-col rounded-lg">
|
||||||
{"C:\\WIRE>"}
|
|
||||||
<textarea
|
<textarea
|
||||||
name="com"
|
name="com"
|
||||||
wrap="soft"
|
wrap="soft"
|
||||||
className="shadow-lg w-full px-4 py-3 h-28 border-none bg-black text-white"
|
className="shadow-lg w-full px-4 py-3 border-blue-500 bg-black text-white"
|
||||||
value={comment}
|
value={comment}
|
||||||
onChange={(e) => setComment(e.target.value)}
|
onChange={(e) => setComment(e.target.value)}
|
||||||
|
rows={comment.split('\n').length || 1}
|
||||||
/>
|
/>
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
{file !== "" && (
|
{file !== "" && (
|
||||||
@ -172,10 +172,10 @@ const NewNoteCard = ({
|
|||||||
ref={emojiRef}
|
ref={emojiRef}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<FaceSmileIcon className="h-4 w-4 text-neutral-400 cursor-pointer" onClick={pickEmoji} />
|
<PlusCircleIcon className="h-4 w-4 text-neutral-400 cursor-pointer" onClick={pickEmoji} />
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<ArrowUpTrayIcon
|
<ServerIcon
|
||||||
className="h-4 w-4 text-neutral-400 cursor-pointer"
|
className="h-4 w-4 text-neutral-400 cursor-pointer"
|
||||||
onClick={() => document.getElementById("file_input")?.click()}
|
onClick={() => document.getElementById("file_input")?.click()}
|
||||||
/>
|
/>
|
||||||
|
@ -10,7 +10,7 @@ export default function Header() {
|
|||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<img src="/icon.png" className="h-12" alt="logo" />
|
<img src="/icon.png" className="h-12" alt="logo" />
|
||||||
<span className="font-semibold text-white">
|
<span className="font-semibold text-white">
|
||||||
{'>'}.. Wired
|
{"~\\WIRED>"}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
@ -1,95 +1,95 @@
|
|||||||
import {sub, subOnce, unsubAll} from './relays';
|
import { sub, subOnce, unsubAll } from './relays';
|
||||||
import { Event } from 'nostr-tools';
|
import { Event } from 'nostr-tools';
|
||||||
|
|
||||||
type SubCallback = (
|
type SubCallback = (
|
||||||
event: Event,
|
event: Event,
|
||||||
relay: string,
|
relay: string,
|
||||||
) => void;
|
) => void;
|
||||||
|
|
||||||
/** subscribe to global feed */
|
/** subscribe to global feed */
|
||||||
export const subGlobalFeed = (onEvent: SubCallback) => {
|
export const subGlobalFeed = (onEvent: SubCallback) => {
|
||||||
console.info('subscribe to global feed');
|
console.info('subscribe to global feed');
|
||||||
unsubAll();
|
unsubAll();
|
||||||
const now = Math.floor(Date.now() * 0.001);
|
const now = Math.floor(Date.now() * 0.001);
|
||||||
const pubkeys = new Set<string>();
|
const pubkeys = new Set<string>();
|
||||||
const notes = new Set<string>();
|
const notes = new Set<string>();
|
||||||
const prefix = Math.floor(16 / 4); // 4 bits in each '0' character
|
const prefix = Math.floor(16 / 4); // 4 bits in each '0' character
|
||||||
sub({ // get past events
|
sub({ // get past events
|
||||||
cb: (evt, relay) => {
|
cb: (evt, relay) => {
|
||||||
pubkeys.add(evt.pubkey);
|
pubkeys.add(evt.pubkey);
|
||||||
notes.add(evt.id);
|
notes.add(evt.id);
|
||||||
onEvent(evt, relay);
|
onEvent(evt, relay);
|
||||||
},
|
},
|
||||||
filter: {
|
filter: {
|
||||||
...(prefix && {ids: ['0'.repeat(prefix)]}),
|
...(prefix && { ids: ['0'.repeat(prefix)] }),
|
||||||
kinds: [1],
|
kinds: [1],
|
||||||
since: Math.floor((Date.now() * 0.001) - (24 * 60 * 60)),
|
since: Math.floor((Date.now() * 0.001) - (24 * 60 * 60)),
|
||||||
limit: 500,
|
limit: 500,
|
||||||
},
|
},
|
||||||
unsub: true
|
unsub: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// // New Callback to only add events that pass the PoW requirement
|
|
||||||
// const powFilteredCallback = (evt: Event, relay: string) => {
|
|
||||||
// if (getPow(evt.id) > 2) { // Replace '5' with your actual PoW requirement
|
|
||||||
// pubkeys.add(evt.pubkey);
|
|
||||||
// notes.add(evt.id);
|
|
||||||
// onEvent(evt, relay);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
setTimeout(() => {
|
// // New Callback to only add events that pass the PoW requirement
|
||||||
// get profile info
|
// const powFilteredCallback = (evt: Event, relay: string) => {
|
||||||
sub({
|
// if (getPow(evt.id) > 2) { // Replace '5' with your actual PoW requirement
|
||||||
cb: onEvent,
|
// pubkeys.add(evt.pubkey);
|
||||||
filter: {
|
// notes.add(evt.id);
|
||||||
authors: Array.from(pubkeys),
|
// onEvent(evt, relay);
|
||||||
kinds: [0],
|
// }
|
||||||
limit: pubkeys.size,
|
// };
|
||||||
},
|
|
||||||
unsub: true,
|
|
||||||
});
|
|
||||||
pubkeys.clear();
|
|
||||||
|
|
||||||
sub({
|
|
||||||
cb: onEvent,
|
|
||||||
filter: {
|
|
||||||
'#e': Array.from(notes),
|
|
||||||
kinds: [1],
|
|
||||||
},
|
|
||||||
unsub: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
notes.clear();
|
setTimeout(() => {
|
||||||
}, 2000);
|
// get profile info
|
||||||
|
|
||||||
// subscribe to future notes, reactions and profile updates
|
|
||||||
sub({
|
sub({
|
||||||
cb: (evt, relay) => {
|
cb: onEvent,
|
||||||
onEvent(evt, relay);
|
|
||||||
if (
|
|
||||||
evt.kind !== 1
|
|
||||||
|| pubkeys.has(evt.pubkey)
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
subOnce({ // get profile data
|
|
||||||
relay,
|
|
||||||
cb: onEvent,
|
|
||||||
filter: {
|
|
||||||
authors: [evt.pubkey],
|
|
||||||
kinds: [0],
|
|
||||||
limit: 1,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
filter: {
|
filter: {
|
||||||
...(prefix && {ids: ['0'.repeat(prefix)]}),
|
authors: Array.from(pubkeys),
|
||||||
kinds: [1],
|
kinds: [0],
|
||||||
since: now,
|
limit: pubkeys.size,
|
||||||
},
|
},
|
||||||
|
unsub: true,
|
||||||
});
|
});
|
||||||
};
|
pubkeys.clear();
|
||||||
|
|
||||||
|
sub({
|
||||||
|
cb: onEvent,
|
||||||
|
filter: {
|
||||||
|
'#e': Array.from(notes),
|
||||||
|
kinds: [1],
|
||||||
|
},
|
||||||
|
unsub: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
notes.clear();
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
// subscribe to future notes, reactions and profile updates
|
||||||
|
sub({
|
||||||
|
cb: (evt, relay) => {
|
||||||
|
onEvent(evt, relay);
|
||||||
|
if (
|
||||||
|
evt.kind !== 1
|
||||||
|
|| pubkeys.has(evt.pubkey)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
subOnce({ // get profile data
|
||||||
|
relay,
|
||||||
|
cb: onEvent,
|
||||||
|
filter: {
|
||||||
|
authors: [evt.pubkey],
|
||||||
|
kinds: [0],
|
||||||
|
limit: 1,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
filter: {
|
||||||
|
...(prefix && { ids: ['0'.repeat(prefix)] }),
|
||||||
|
kinds: [1],
|
||||||
|
since: now,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/** subscribe to global feed */
|
/** subscribe to global feed */
|
||||||
export const simpleSub24hFeed = (onEvent: SubCallback) => {
|
export const simpleSub24hFeed = (onEvent: SubCallback) => {
|
||||||
@ -158,16 +158,14 @@ export const subNote = (
|
|||||||
}, 2000);
|
}, 2000);
|
||||||
|
|
||||||
replies.add(eventId);
|
replies.add(eventId);
|
||||||
setTimeout(() => {
|
// subscribe to future replies
|
||||||
sub({
|
sub({
|
||||||
cb: onReply,
|
cb: onReply,
|
||||||
filter: {
|
filter: {
|
||||||
'#e': [eventId],
|
'#e': [eventId],
|
||||||
kinds: [1],
|
kinds: [1],
|
||||||
},
|
},
|
||||||
unsub: true, // TODO: probably keep this subscription also after onReply/unsubAll
|
});
|
||||||
});
|
|
||||||
}, 200);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** quick subscribe to a note id (nip-19) */
|
/** quick subscribe to a note id (nip-19) */
|
||||||
|
Loading…
Reference in New Issue
Block a user