remix-nlux
Version:
Remix IDE NLUX integration. Remix IDE is the leading IDE for building and deploying smart contracts on Ethereum. NLUX is a JavaScript and React library for building conversational AI experiences.
21 lines (17 loc) • 717 B
text/typescript
import {MutableRefObject, useCallback} from 'react';
import {AutoScrollController} from '@shared/interactions/autoScroll/type';
type LastActiveSegmentData = {uid: string; div: HTMLDivElement};
export const useLastActiveSegmentChangeHandler = (
autoScrollController: AutoScrollController | undefined,
lastActiveSegmentIdRef: MutableRefObject<string | undefined>,
) => {
return useCallback((data: LastActiveSegmentData | undefined) => {
if (!autoScrollController) {
return;
}
if (data) {
lastActiveSegmentIdRef.current = data.uid;
autoScrollController.handleNewChatSegmentAdded(data.uid, data.div);
}
}, [autoScrollController]);
};