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