//
// Copyright 2023 DXOS.org
//
import { useEffect, useState } from 'react';
import { useDevtools, useStream } from '@dxos/react-client/devtools';
import { useDevtoolsState } from './useDevtoolsContext';
export const useFeedMessages = ({ feedKey, maxBlocks = 100 }) => {
    const devtoolsHost = useDevtools();
    const { space } = useDevtoolsState();
    // TODO(wittjosiah): FeedMessageBlock.
    const [messages, setMessages] = useState([]);
    const { blocks } = useStream(() => devtoolsHost.subscribeToFeedBlocks({ spaceKey: space?.key, feedKey, maxBlocks }), {}, [space, feedKey]);
    useEffect(() => {
        setMessages(blocks ?? []);
    }, [blocks]);
    useEffect(() => {
        setMessages(blocks ?? []);
    }, [blocks]);
    return messages;
};
//# sourceMappingURL=useFeedMessages.js.map