Skip to content

Commit

Permalink
fix(core): ai chat panel content will be inconsistent when switching …
Browse files Browse the repository at this point in the history
…to journals (#9288)

Fix issue [BS-2153](https://linear.app/affine-design/issue/BS-2153).

Optimize DOM reuse by explicitly providing an identifier (similar to React's key).
  • Loading branch information
akumatus committed Dec 24, 2024
1 parent 20aca4d commit 6c0544b
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,19 @@ export class ChatPanelMessages extends WithDisposable(ShadowlessElement) {
</div>
${this._renderAIOnboarding()}
</div> `
: repeat(filteredItems, (item, index) => {
const isLast = index === filteredItems.length - 1;
return html`<div class="message">
${this.renderAvatar(item)}
<div class="item-wrapper">${this.renderItem(item, isLast)}</div>
</div>`;
})}
: repeat(
filteredItems,
item => ('role' in item ? item.id : item.sessionId),
(item, index) => {
const isLast = index === filteredItems.length - 1;
return html`<div class="message">
${this.renderAvatar(item)}
<div class="item-wrapper">
${this.renderItem(item, isLast)}
</div>
</div>`;
}
)}
<chat-cards
.updateContext=${this.updateContext}
.host=${this.host}
Expand Down

0 comments on commit 6c0544b

Please sign in to comment.