Fix global tab
This commit is contained in:
parent
1e5b573045
commit
9f00157bdc
@ -22,7 +22,6 @@ export interface TimelineProps {
|
||||
method: "TIME_RANGE" | "LIMIT_UNTIL";
|
||||
ignoreModeration?: boolean;
|
||||
window?: number;
|
||||
relay?: string;
|
||||
now?: number;
|
||||
loadMore?: boolean;
|
||||
noSort?: boolean;
|
||||
@ -36,7 +35,6 @@ const Timeline = (props: TimelineProps) => {
|
||||
return {
|
||||
method: props.method,
|
||||
window: props.window,
|
||||
relay: props.relay,
|
||||
now: props.now,
|
||||
};
|
||||
}, [props]);
|
||||
|
@ -11,7 +11,6 @@ import { SearchRelays } from "Const";
|
||||
export interface TimelineFeedOptions {
|
||||
method: "TIME_RANGE" | "LIMIT_UNTIL";
|
||||
window?: number;
|
||||
relay?: string;
|
||||
now?: number;
|
||||
}
|
||||
|
||||
@ -19,6 +18,7 @@ export interface TimelineSubject {
|
||||
type: "pubkey" | "hashtag" | "global" | "ptag" | "post_keyword" | "profile_keyword";
|
||||
discriminator: string;
|
||||
items: string[];
|
||||
relay?: string;
|
||||
}
|
||||
|
||||
export type TimelineFeed = ReturnType<typeof useTimelineFeed>;
|
||||
@ -44,11 +44,8 @@ export default function useTimelineFeed(subject: TimelineSubject, options: Timel
|
||||
: [EventKind.TextNote, EventKind.Repost, EventKind.Polls]
|
||||
);
|
||||
|
||||
if (options.relay) {
|
||||
b.withOptions({
|
||||
leaveOpen: false,
|
||||
relays: [options.relay],
|
||||
});
|
||||
if (subject.relay) {
|
||||
f.relay(subject.relay);
|
||||
}
|
||||
switch (subject.type) {
|
||||
case "pubkey": {
|
||||
@ -132,7 +129,7 @@ export default function useTimelineFeed(subject: TimelineSubject, options: Timel
|
||||
// clear store if changing relays
|
||||
main.clear();
|
||||
latest.clear();
|
||||
}, [options.relay]);
|
||||
}, [subject.relay]);
|
||||
|
||||
function getParentEvents() {
|
||||
if (main.data) {
|
||||
|
@ -127,6 +127,7 @@ const GlobalTab = () => {
|
||||
const subject: TimelineSubject = {
|
||||
type: "global",
|
||||
items: [],
|
||||
relay: relay?.url,
|
||||
discriminator: `all-${sha256(relay?.url ?? "").slice(0, 12)}`,
|
||||
};
|
||||
|
||||
@ -188,9 +189,7 @@ const GlobalTab = () => {
|
||||
return (
|
||||
<>
|
||||
{globalRelaySelector()}
|
||||
{relay && (
|
||||
<Timeline subject={subject} postsOnly={false} method={"TIME_RANGE"} window={600} relay={relay.url} now={now} />
|
||||
)}
|
||||
{relay && <Timeline subject={subject} postsOnly={false} method={"TIME_RANGE"} window={600} now={now} />}
|
||||
</>
|
||||
);
|
||||
};
|
||||
@ -206,7 +205,7 @@ const NotesTab = () => {
|
||||
return (
|
||||
<>
|
||||
<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)}`,
|
||||
};
|
||||
|
||||
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 { tag } = useParams();
|
||||
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 = [
|
||||
|
@ -40,7 +40,6 @@ export interface BuiltRawReqFilter {
|
||||
|
||||
export interface RequestBuilderOptions {
|
||||
leaveOpen?: boolean;
|
||||
relays?: Array<string>;
|
||||
/**
|
||||
* 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> {
|
||||
// use the explicit relay list first
|
||||
if (this.#relays.size > 0) {
|
||||
// always query our default relay lists too when using explicit relays
|
||||
// these explicit relays may not always be available
|
||||
return [...this.#relays, ""].map(r => {
|
||||
return [...this.#relays].map(r => {
|
||||
return {
|
||||
filters: [this.#filter],
|
||||
relay: r,
|
||||
|
Loading…
x
Reference in New Issue
Block a user