Skip to content

Commit

Permalink
Chat example: update nick in message history on peer announce
Browse files Browse the repository at this point in the history
  • Loading branch information
caolan committed Oct 7, 2024
1 parent 3572631 commit 9b3f1ca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 7 additions & 10 deletions examples/chat/components/message-history.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ export default class ChatMessageHistory extends HTMLElement {
}

connectedCallback() {
this.shadow = this.attachShadow({mode: "open"});
this.shadow.innerHTML = `
<link rel="stylesheet" href="style.css">
<pre id="message-history"></pre>
`;
this.history = this.shadow.getElementById('message-history');
this.stop = watch([local_peer_id, selected_announcement, messages], () => {
this.updateMessages();
});
this.stop = watch([
local_peer_id,
selected_announcement,
announcements,
messages,
], () => this.updateMessages());
this.updateMessages();
}

Expand Down Expand Up @@ -52,7 +49,7 @@ export default class ChatMessageHistory extends HTMLElement {
}
}
}
this.history.textContent = txt;
this.textContent = txt;
}
}

Expand Down
2 changes: 2 additions & 0 deletions examples/chat/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ chat-message-history {
flex-grow: 1;
flex-shrink: 1;
padding: 1em;
font-family: monospace;
white-space: pre;
}

#send-message-form {
Expand Down

0 comments on commit 9b3f1ca

Please sign in to comment.