chore: formatting
This commit is contained in:
@ -9,7 +9,7 @@ import { TimelineFragment } from "./TimelineFragment";
|
||||
|
||||
export interface TimelineChunkProps {
|
||||
id: string;
|
||||
chunk: WindowChunk,
|
||||
chunk: WindowChunk;
|
||||
builder: (rb: RequestBuilder) => void;
|
||||
noteFilter?: (ev: NostrEvent) => boolean;
|
||||
noteRenderer?: (ev: NostrEvent) => ReactNode;
|
||||
@ -33,12 +33,14 @@ export default function TimelineChunk(props: TimelineChunkProps) {
|
||||
|
||||
const feed = useRequestBuilder(sub);
|
||||
|
||||
return <TimelineFragment
|
||||
return (
|
||||
<TimelineFragment
|
||||
frag={{
|
||||
events: feed.filter(a => props.noteFilter?.(a) ?? true),
|
||||
refTime: props.chunk.until
|
||||
refTime: props.chunk.until,
|
||||
}}
|
||||
noteOnClick={props.noteOnClick}
|
||||
noteRenderer={props.noteRenderer}
|
||||
/>
|
||||
);
|
||||
}
|
@ -39,27 +39,27 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
|
||||
const { isFollowing, followList } = useFollowsControls();
|
||||
const { chunks, showMore } = useTimelineChunks({
|
||||
now: openedAt,
|
||||
firstChunkSize: Hour * 2
|
||||
firstChunkSize: Hour * 2,
|
||||
});
|
||||
|
||||
const builder = (rb: RequestBuilder) => {
|
||||
rb.withFilter()
|
||||
.authors(followList)
|
||||
.kinds([EventKind.TextNote, EventKind.Repost, EventKind.Polls]);
|
||||
rb.withFilter().authors(followList).kinds([EventKind.TextNote, EventKind.Repost, EventKind.Polls]);
|
||||
};
|
||||
|
||||
const filterEvents = (a: NostrEvent) =>
|
||||
(props.noteFilter?.(a) ?? true)
|
||||
&& (props.postsOnly ? !a.tags.some(b => b[0] === "e" || b[0] === "a") : true)
|
||||
&& (isFollowing(a.pubkey) || a.tags.filter(a => a[0] === "t").length < 5);
|
||||
(props.noteFilter?.(a) ?? true) &&
|
||||
(props.postsOnly ? !a.tags.some(b => b[0] === "e" || b[0] === "a") : true) &&
|
||||
(isFollowing(a.pubkey) || a.tags.filter(a => a[0] === "t").length < 5);
|
||||
|
||||
return <>
|
||||
return (
|
||||
<>
|
||||
<DisplayAsSelector
|
||||
show={props.showDisplayAsSelector}
|
||||
activeSelection={displayAs}
|
||||
onSelect={(displayAs: DisplayAs) => setDisplayAs(displayAs)}
|
||||
/>
|
||||
{chunks.map(c => <TimelineChunk
|
||||
{chunks.map(c => (
|
||||
<TimelineChunk
|
||||
key={c.until}
|
||||
id="follows"
|
||||
chunk={c}
|
||||
@ -67,9 +67,11 @@ const TimelineFollows = (props: TimelineFollowsProps) => {
|
||||
noteFilter={filterEvents}
|
||||
noteOnClick={props.noteOnClick}
|
||||
noteRenderer={props.noteRenderer}
|
||||
/>)}
|
||||
/>
|
||||
))}
|
||||
<AutoLoadMore onClick={() => showMore()} />
|
||||
</>;
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default TimelineFollows;
|
||||
|
@ -5,18 +5,18 @@ export interface WindowChunk {
|
||||
until: number;
|
||||
}
|
||||
|
||||
export default function useTimelineChunks(opt: { window?: number; firstChunkSize?: number, now: number }) {
|
||||
const [windowSize] = useState(opt.window ?? (60 * 60 * 2));
|
||||
export default function useTimelineChunks(opt: { window?: number; firstChunkSize?: number; now: number }) {
|
||||
const [windowSize] = useState(opt.window ?? 60 * 60 * 2);
|
||||
const [windows, setWindows] = useState(1);
|
||||
|
||||
const chunks: Array<WindowChunk> = [];
|
||||
for (let x = 0; x < windows; x++) {
|
||||
// offset from now going backwards in time
|
||||
const offset = opt.now - (windowSize * (x - 1));
|
||||
const offset = opt.now - windowSize * (x - 1);
|
||||
const size = x === 0 && opt.firstChunkSize ? opt.firstChunkSize : windowSize;
|
||||
chunks.push({
|
||||
since: offset - size,
|
||||
until: offset
|
||||
until: offset,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -100,7 +100,8 @@ export type ConnectionBuilder<T extends ConnectionType> = (
|
||||
*/
|
||||
export class DefaultConnectionPool<T extends ConnectionType = Connection>
|
||||
extends EventEmitter<ConnectionPoolEvents>
|
||||
implements ConnectionPool {
|
||||
implements ConnectionPool
|
||||
{
|
||||
#system: SystemInterface;
|
||||
#log = debug("ConnectionPool");
|
||||
|
||||
|
@ -154,7 +154,6 @@ export class RequestBuilder {
|
||||
return acc;
|
||||
}, new Map<string, Array<FlatReqFilter>>());
|
||||
|
||||
|
||||
const ret = [];
|
||||
for (const [k, v] of relayMerged.entries()) {
|
||||
const filters = system.optimizer.flatMerge(v);
|
||||
|
Reference in New Issue
Block a user