mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
fix(desktop): refetch home feed immediately on live mentions (#230)
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user