From 0bcd044f10b796222ede6aa3729f3ef3893f14c6 Mon Sep 17 00:00:00 2001 From: Tom Lebreux Date: Mon, 31 May 2021 22:39:35 -0400 Subject: [PATCH] Linkify channel names --- components/app.js | 17 ++++++++++++++- components/buffer-header.js | 2 +- components/buffer.js | 9 +++++--- lib/linkify.js | 42 ++++++++++++++++++++++++++++++++++--- 4 files changed, 62 insertions(+), 8 deletions(-) diff --git a/components/app.js b/components/app.js index 0f55d68..5fc2034 100644 --- a/components/app.js +++ b/components/app.js @@ -225,6 +225,7 @@ export default class App extends Component { this.toggleBufferList = this.toggleBufferList.bind(this); this.toggleMemberList = this.toggleMemberList.bind(this); this.handleComposerSubmit = this.handleComposerSubmit.bind(this); + this.handleChannelClick = this.handleChannelClick.bind(this); this.handleNickClick = this.handleNickClick.bind(this); this.autocomplete = this.autocomplete.bind(this); this.handleBufferScrollTop = this.handleBufferScrollTop.bind(this); @@ -908,6 +909,16 @@ export default class App extends Component { this.connect(connectParams); } + handleChannelClick(channel) { + var netID = getActiveNetworkID(this.state); + var buf = getBuffer(this.state, { network: netID, name: channel }); + if (buf) { + this.switchBuffer(buf.id); + } else { + this.open(channel); + } + } + handleNickClick(nick) { this.open(nick); } @@ -1361,6 +1372,7 @@ export default class App extends Component { network=${activeNetwork} isBouncer=${isBouncer} bouncerNetwork=${activeBouncerNetwork} + onChannelClick=${this.handleChannelClick} onClose=${() => this.close(activeBuffer)} onJoin=${() => this.handleJoinClick(activeBuffer.network)} onAddNetwork=${this.handleAddNetworkClick} @@ -1475,7 +1487,10 @@ export default class App extends Component { onScrollTop=${this.handleBufferScrollTop} >
- <${Buffer} buffer=${activeBuffer} onNickClick=${this.handleNickClick}/> + <${Buffer} + buffer=${activeBuffer} + onChannelClick=${this.handleChannelClick} + onNickClick=${this.handleNickClick}/>
${memberList} diff --git a/components/buffer-header.js b/components/buffer-header.js index 4fe0835..586c467 100644 --- a/components/buffer-header.js +++ b/components/buffer-header.js @@ -114,7 +114,7 @@ export default function BufferHeader(props) { break; case BufferType.CHANNEL: if (props.buffer.topic) { - description = linkify(stripANSI(props.buffer.topic)); + description = linkify(stripANSI(props.buffer.topic), props.onChannelClick); } actions = html`