fix(desktop): refetch home feed immediately on live mentions (#230)

This commit is contained in:
Wes
2026-04-03 18:49:43 -07:00
committed by GitHub
parent 5923a7ba1c
commit bf083dda5d
8 changed files with 616 additions and 147 deletions
@@ -8,6 +8,7 @@ import {
import type { PresenceStatus, RelayEvent } from "@/shared/api/types";
import {
CHANNEL_EVENT_KINDS,
HOME_MENTION_EVENT_KINDS,
KIND_STREAM_MESSAGE,
KIND_TYPING_INDICATOR,
} from "@/shared/constants/kinds";
@@ -174,6 +175,17 @@ export class RelayClient {
return this.subscribe(this.buildGlobalStreamFilter(50), onEvent);
}
async subscribeToChannelMentionEvents(
channelId: string,
pubkey: string,
onEvent: (event: RelayEvent) => void,
) {
return this.subscribe(
this.buildChannelMentionFilter(channelId, pubkey, 50),
onEvent,
);
}
async preconnect() {
this.keepAliveRequested = true;
await this.ensureConnected();
@@ -275,6 +287,20 @@ export class RelayClient {
};
}
private buildChannelMentionFilter(
channelId: string,
pubkey: string,
limit: number,
): RelaySubscriptionFilter {
return {
kinds: [...HOME_MENTION_EVENT_KINDS],
"#h": [channelId],
"#p": [pubkey],
limit,
since: Math.floor(Date.now() / 1_000),
};
}
private async subscribe(
filter: RelaySubscriptionFilter,
onEvent: (event: RelayEvent) => void,
+1 -2
View File
@@ -2,11 +2,10 @@ import type { RelayEvent } from "@/shared/api/types";
export type RelaySubscriptionFilter = {
kinds: number[];
"#h"?: string[];
limit: number;
since?: number;
until?: number;
};
} & Partial<Record<`#${string}`, string[]>>;
type HistorySubscription = {
mode: "history";