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.
30 lines (26 loc) • 1.1 kB
text/typescript
import {ChatSegmentStatus} from '@shared/types/chatSegment/chatSegment';
import {debug} from '@shared/utils/debug';
import {getChatSegmentClassName} from '@shared/utils/dom/getChatSegmentClassName';
import {CompUpdater} from '../../../types/comp';
import {CompChatSegmentActions, CompChatSegmentElements, CompChatSegmentProps} from './chatSegment.types';
export const updateChatSegment: CompUpdater<
CompChatSegmentProps, CompChatSegmentElements, CompChatSegmentActions
> = ({propName, newValue, dom}) => {
if (propName === 'status') {
const rootContainer: HTMLElement | undefined = dom.elements?.chatSegmentContainer;
if (!rootContainer) {
return;
}
const newStatus = newValue as ChatSegmentStatus;
rootContainer.className = getChatSegmentClassName(newStatus);
if (newStatus === 'active') {
dom.actions?.showLoader();
} else {
dom.actions?.hideLoader();
}
}
if (propName === 'uid') {
debug('updateChatSegment — uid is not updatable');
// Do nothing
}
};