Skip to content

Commit a38dbc9

Browse files
committed
Use optional chaining to improve readability
1 parent d31977a commit a38dbc9

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

ai/ai-react-app/src/components/Layout/LeftSidebar.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,7 @@ const LeftSidebar: React.FC<LeftSidebarProps> = ({
4646
? { parts: [{ text: newInstructionText }] }
4747
: undefined;
4848

49-
const currentInstruction = prevParams.systemInstruction;
50-
const currentInstructionText =
51-
currentInstruction &&
52-
typeof currentInstruction === "object" &&
53-
"parts" in currentInstruction &&
54-
Array.isArray(currentInstruction.parts) &&
55-
currentInstruction.parts.length > 0 &&
56-
"text" in currentInstruction.parts[0]
57-
? currentInstruction.parts[0].text
58-
: undefined;
49+
const currentInstructionText = prevParams.systemInstruction?.parts?.[0]?.text;
5950

6051
// Only update if the text content has actually changed.
6152
if ((newInstructionText || "") !== (currentInstructionText || "")) {

0 commit comments

Comments
 (0)