Fix global tab

This commit is contained in:
Kieran 2023-06-19 10:51:42 +01:00
parent 1e5b573045
commit 9f00157bdc
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
4 changed files with 10 additions and 19 deletions

View File

@ -22,7 +22,6 @@ export interface TimelineProps {
method: "TIME_RANGE" | "LIMIT_UNTIL"; method: "TIME_RANGE" | "LIMIT_UNTIL";
ignoreModeration?: boolean; ignoreModeration?: boolean;
window?: number; window?: number;
relay?: string;
now?: number; now?: number;
loadMore?: boolean; loadMore?: boolean;
noSort?: boolean; noSort?: boolean;
@ -36,7 +35,6 @@ const Timeline = (props: TimelineProps) => {
return { return {
method: props.method, method: props.method,
window: props.window, window: props.window,
relay: props.relay,
now: props.now, now: props.now,
}; };
}, [props]); }, [props]);

View File

@ -11,7 +11,6 @@ import { SearchRelays } from "Const";
export interface TimelineFeedOptions { export interface TimelineFeedOptions {
method: "TIME_RANGE" | "LIMIT_UNTIL"; method: "TIME_RANGE" | "LIMIT_UNTIL";
window?: number; window?: number;
relay?: string;
now?: number; now?: number;
} }
@ -19,6 +18,7 @@ export interface TimelineSubject {
type: "pubkey" | "hashtag" | "global" | "ptag" | "post_keyword" | "profile_keyword"; type: "pubkey" | "hashtag" | "global" | "ptag" | "post_keyword" | "profile_keyword";
discriminator: string; discriminator: string;
items: string[]; items: string[];
relay?: string;
} }
export type TimelineFeed = ReturnType<typeof useTimelineFeed>; export type TimelineFeed = ReturnType<typeof useTimelineFeed>;
@ -44,11 +44,8 @@ export default function useTimelineFeed(subject: TimelineSubject, options: Timel
: [EventKind.TextNote, EventKind.Repost, EventKind.Polls] : [EventKind.TextNote, EventKind.Repost, EventKind.Polls]
); );
if (options.relay) { if (subject.relay) {
b.withOptions({ f.relay(subject.relay);
leaveOpen: false,
relays: [options.relay],
});
} }
switch (subject.type) { switch (subject.type) {
case "pubkey": { case "pubkey": {
@ -132,7 +129,7 @@ export default function useTimelineFeed(subject: TimelineSubject, options: Timel
// clear store if changing relays // clear store if changing relays
main.clear(); main.clear();
latest.clear(); latest.clear();
}, [options.relay]); }, [subject.relay]);
function getParentEvents() { function getParentEvents() {
if (main.data) { if (main.data) {

View File

@ -127,6 +127,7 @@ const GlobalTab = () => {
const subject: TimelineSubject = { const subject: TimelineSubject = {
type: "global", type: "global",
items: [], items: [],
relay: relay?.url,
discriminator: `all-${sha256(relay?.url ?? "").slice(0, 12)}`, discriminator: `all-${sha256(relay?.url ?? "").slice(0, 12)}`,
}; };
@ -188,9 +189,7 @@ const GlobalTab = () => {
return ( return (
<> <>
{globalRelaySelector()} {globalRelaySelector()}
{relay && ( {relay && <Timeline subject={subject} postsOnly={false} method={"TIME_RANGE"} window={600} now={now} />}
<Timeline subject={subject} postsOnly={false} method={"TIME_RANGE"} window={600} relay={relay.url} now={now} />
)}
</> </>
); );
}; };
@ -206,7 +205,7 @@ const NotesTab = () => {
return ( return (
<> <>
<FollowsHint /> <FollowsHint />
<Timeline subject={subject} postsOnly={true} method={"TIME_RANGE"} window={undefined} relay={undefined} /> <Timeline subject={subject} postsOnly={true} method={"TIME_RANGE"} />
</> </>
); );
}; };
@ -219,14 +218,14 @@ const ConversationsTab = () => {
discriminator: `follows:${publicKey?.slice(0, 12)}`, discriminator: `follows:${publicKey?.slice(0, 12)}`,
}; };
return <Timeline subject={subject} postsOnly={false} method={"TIME_RANGE"} window={undefined} relay={undefined} />; return <Timeline subject={subject} postsOnly={false} method={"TIME_RANGE"} />;
}; };
const TagsTab = () => { const TagsTab = () => {
const { tag } = useParams(); const { tag } = useParams();
const subject: TimelineSubject = { type: "hashtag", items: [tag ?? ""], discriminator: `tags-${tag}` }; const subject: TimelineSubject = { type: "hashtag", items: [tag ?? ""], discriminator: `tags-${tag}` };
return <Timeline subject={subject} postsOnly={false} method={"TIME_RANGE"} window={undefined} relay={undefined} />; return <Timeline subject={subject} postsOnly={false} method={"TIME_RANGE"} />;
}; };
export const RootRoutes = [ export const RootRoutes = [

View File

@ -40,7 +40,6 @@ export interface BuiltRawReqFilter {
export interface RequestBuilderOptions { export interface RequestBuilderOptions {
leaveOpen?: boolean; leaveOpen?: boolean;
relays?: Array<string>;
/** /**
* Do not apply diff logic and always use full filters for query * Do not apply diff logic and always use full filters for query
*/ */
@ -222,9 +221,7 @@ export class RequestFilterBuilder {
build(relays: RelayCache, id: string): Array<BuiltRawReqFilter> { build(relays: RelayCache, id: string): Array<BuiltRawReqFilter> {
// use the explicit relay list first // use the explicit relay list first
if (this.#relays.size > 0) { if (this.#relays.size > 0) {
// always query our default relay lists too when using explicit relays return [...this.#relays].map(r => {
// these explicit relays may not always be available
return [...this.#relays, ""].map(r => {
return { return {
filters: [this.#filter], filters: [this.#filter],
relay: r, relay: r,