mirror of
https://github.com/block/buzz.git
synced 2026-11-09 02:41:57 +00: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,
|
||||
|
||||
Reference in New Issue
Block a user