mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-11-14 19:25:26 -05:00
Sort buffers and members
This commit is contained in:
parent
806686bd49
commit
028c6fd8b3
2 changed files with 20 additions and 2 deletions
|
@ -39,10 +39,28 @@ function BufferItem(props) {
|
|||
`;
|
||||
}
|
||||
|
||||
function compareBuffers(a, b) {
|
||||
if (a.type == BufferType.SERVER) {
|
||||
return -1;
|
||||
}
|
||||
if (b.type == BufferType.SERVER) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (a.name > b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name < b.name) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
export default function BufferList(props) {
|
||||
return html`
|
||||
<ul id="buffer-list">
|
||||
${Array.from(this.props.buffers.values()).map(buf => html`
|
||||
${Array.from(this.props.buffers.values()).sort(compareBuffers).map(buf => html`
|
||||
<${BufferItem} buffer=${buf} onClick=${() => props.onBufferClick(buf.name)} active=${props.activeBuffer == buf.name}/>
|
||||
`)}
|
||||
</ul>
|
||||
|
|
|
@ -17,7 +17,7 @@ function MemberItem(props) {
|
|||
export default function MemberList(props) {
|
||||
return html`
|
||||
<ul id="buffer-list">
|
||||
${Array.from(this.props.members.entries()).map(([nick, membership]) => html`
|
||||
${Array.from(this.props.members.entries()).sort().map(([nick, membership]) => html`
|
||||
<${MemberItem} key=${nick} nick=${nick} membership=${membership} onClick=${() => props.onNickClick(nick)}/>
|
||||
`)}
|
||||
</ul>
|
||||
|
|
Loading…
Reference in a new issue