File size: 472 Bytes
3d700dd
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { shouldRenderEvent } from "#/components/conversation-events/chat/event-content-helpers/should-render-event";
import { useEventStore } from "#/stores/use-event-store";

export const getLastRenderableEventId = (): string | null => {
  const { uiEvents } = useEventStore.getState();

  for (let index = uiEvents.length - 1; index >= 0; index -= 1) {
    const event = uiEvents[index];
    if (shouldRenderEvent(event)) return String(event.id);
  }

  return null;
};