Skip to content

Commit e22c8b3

Browse files
committed
chore: Address code review feedback
1 parent 8477190 commit e22c8b3

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

js/chat/chat.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class ChatInput extends LightElement {
124124
private _disabled = false;
125125

126126
@property() placeholder = "Enter a message...";
127+
// disabled is reflected manually because `reflect: true` doesn't work with LightElement
127128
@property({ type: Boolean })
128129
get disabled() {
129130
return this._disabled;
@@ -146,11 +147,12 @@ class ChatInput extends LightElement {
146147

147148
attributeChangedCallback(
148149
name: string,
149-
oldValue: string | null,
150-
newValue: string | null
150+
_old: string | null,
151+
value: string | null
151152
) {
153+
super.attributeChangedCallback(name, _old, value);
152154
if (name === "disabled") {
153-
this.disabled = newValue !== null;
155+
this.disabled = value !== null;
154156
}
155157
}
156158

@@ -335,11 +337,15 @@ class ChatContainer extends LightElement {
335337
this.#appendMessage(event.detail);
336338
}
337339

338-
#appendMessage(message: Message, finalize = true): void {
340+
#initMessage(): void {
339341
this.#removeLoadingMessage();
340342
if (!this.input.disabled) {
341343
this.input.disabled = true;
342344
}
345+
}
346+
347+
#appendMessage(message: Message, finalize = true): void {
348+
this.#initMessage();
343349

344350
const TAG_NAME =
345351
message.role === "user" ? CHAT_USER_MESSAGE_TAG : CHAT_MESSAGE_TAG;

0 commit comments

Comments
 (0)