fix: support setting visibility on initial chat creation (#975)
This commit is contained in:
parent
a3221fbcdc
commit
575c12503c
15 changed files with 158 additions and 32 deletions
|
|
@ -3,14 +3,20 @@
|
|||
import { motion } from 'framer-motion';
|
||||
import { Button } from './ui/button';
|
||||
import { memo } from 'react';
|
||||
import { UseChatHelpers } from '@ai-sdk/react';
|
||||
import type { UseChatHelpers } from '@ai-sdk/react';
|
||||
import type { VisibilityType } from './visibility-selector';
|
||||
|
||||
interface SuggestedActionsProps {
|
||||
chatId: string;
|
||||
append: UseChatHelpers['append'];
|
||||
selectedVisibilityType: VisibilityType;
|
||||
}
|
||||
|
||||
function PureSuggestedActions({ chatId, append }: SuggestedActionsProps) {
|
||||
function PureSuggestedActions({
|
||||
chatId,
|
||||
append,
|
||||
selectedVisibilityType,
|
||||
}: SuggestedActionsProps) {
|
||||
const suggestedActions = [
|
||||
{
|
||||
title: 'What are the advantages',
|
||||
|
|
@ -71,4 +77,13 @@ function PureSuggestedActions({ chatId, append }: SuggestedActionsProps) {
|
|||
);
|
||||
}
|
||||
|
||||
export const SuggestedActions = memo(PureSuggestedActions, () => true);
|
||||
export const SuggestedActions = memo(
|
||||
PureSuggestedActions,
|
||||
(prevProps, nextProps) => {
|
||||
if (prevProps.chatId !== nextProps.chatId) return false;
|
||||
if (prevProps.selectedVisibilityType !== nextProps.selectedVisibilityType)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue