fix crash

This commit is contained in:
Martti Malmi 2023-08-23 22:26:50 +03:00
parent 28b0ad312b
commit 644c266299
2 changed files with 8 additions and 0 deletions

View File

@ -48,6 +48,7 @@ const Note: React.FC<NoteProps> = ({
return filter;
}, [event.id, showReplies]);
const repliesFilterFn = useCallback((e) => getEventReplyingTo(e) === event.id, [event.id]);
const { events: replies } = useSubscribe({
filter: repliesFilter,
filterFn: repliesFilterFn,

View File

@ -32,7 +32,10 @@ const useSubscribe = (ops: SubscribeOptions) => {
mergeSubscriptions = defaultOps.mergeSubscriptions,
} = ops;
const shouldReturnEarly = !enabled || filter.limit === 0;
const getEvents = useCallback(() => {
if (shouldReturnEarly) return [];
// maybe we should still add filter by displaycount?
let e = EventDB.findArray({ ...filter, limit: undefined });
if (filterFn) {
@ -83,6 +86,10 @@ const useSubscribe = (ops: SubscribeOptions) => {
};
}, [loadMore]);
if (shouldReturnEarly) {
return { events: [], loadMore: () => {} };
}
return { events, loadMore };
};