Skip to content
This repository was archived by the owner on Apr 12, 2023. It is now read-only.

Commit 931499f

Browse files
committed
Remove the exit button
It overlaps with the scrollbar, and our interface already uses context menu for leaving a channel.
1 parent c406d0c commit 931499f

File tree

1 file changed

+8
-68
lines changed

1 file changed

+8
-68
lines changed

lib/view/channel-item.js

Lines changed: 8 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class ChannelItem {
2020
}
2121

2222
this.hover = false
23-
this.hoverExitButton = false
2423
this.isSelected = false
2524
this.disabled = false
2625

@@ -30,17 +29,13 @@ class ChannelItem {
3029
this.view.onDraw = this._draw.bind(this)
3130
this.view.onMouseEnter = () => {
3231
this.hover = true
33-
this.hoverExitButton = false
3432
this.view.schedulePaint()
3533
}
3634
this.view.onMouseLeave = () => {
3735
this.hover = false
38-
this.hoverExitButton = false
3936
this.view.schedulePaint()
4037
}
4138
this.view.onMouseUp = this._click.bind(this)
42-
if (channel.type === 'dm')
43-
this.view.onMouseMove = this._updateExitButtonHover.bind(this)
4439
}
4540

4641
unload() {
@@ -114,12 +109,9 @@ class ChannelItem {
114109
// Draw mentions count.
115110
if (this.channel.mentions > 0)
116111
this._drawMentionsCount(painter, mentionsRadius, padding + textRect.width, bounds.height, textRect.height)
117-
// Draw DM-specific items.
118-
if (this.channel.type === 'dm') {
112+
// Draw presence indicator.
113+
if (this.channel.type === 'dm')
119114
this._drawPresenceIndicator(painter, bounds, attributes)
120-
if (this.hover && this.channel.mentions === 0)
121-
this._drawExitButton(painter, bounds, attributes)
122-
}
123115
}
124116

125117
_drawMentionsCount(painter, radius, x, height, textHeight) {
@@ -165,72 +157,20 @@ class ChannelItem {
165157
}
166158
}
167159

168-
_drawExitButton(painter, bounds, attributes) {
169-
const {exitButtonXHeight, exitButtonRadius, padding} = theme.channelItem
170-
const xPos = bounds.width - padding - exitButtonRadius
171-
const arcPos = {x: xPos, y: bounds.height / 2}
172-
painter.setStrokeColor(this.hoverExitButton ? theme.channelItem.selectedColor
173-
: theme.channelItem.normalColor)
174-
painter.beginPath()
175-
painter.setLineWidth(1)
176-
painter.arc(arcPos, exitButtonRadius, 0, 2 * Math.PI)
177-
painter.translate({x: xPos, y: (bounds.height - exitButtonXHeight) / 2})
178-
painter.moveTo({x: -(exitButtonXHeight / 2), y: 0})
179-
painter.lineTo({x: exitButtonXHeight / 2, y: exitButtonXHeight})
180-
painter.moveTo({x: - (exitButtonXHeight / 2), y: exitButtonXHeight})
181-
painter.lineTo({x: exitButtonXHeight / 2, y: 0})
182-
painter.stroke()
183-
}
184-
185-
_updateExitButtonHover(view, event) {
186-
if (this.channel.mentions > 0) {
187-
this.hoverExitButton = false
188-
this.view.schedulePaint()
189-
return
190-
}
191-
const {exitButtonXHeight, exitButtonRadius, padding} = theme.channelItem
192-
const bounds = view.getBounds()
193-
const rect = {
194-
left: bounds.width - padding - exitButtonRadius * 2,
195-
top: bounds.height / 2 - exitButtonRadius,
196-
right: bounds.width - padding,
197-
bottom: bounds.height - exitButtonRadius,
198-
}
199-
const hoverExitButton = event.positionInView.x >= rect.left &
200-
event.positionInView.x <= rect.right &
201-
event.positionInView.y >= rect.top &
202-
event.positionInView.y <= rect.bottom
203-
if (this.hoverExitButton != hoverExitButton) {
204-
this.hoverExitButton = hoverExitButton
205-
this.view.schedulePaint()
206-
}
207-
}
208-
209160
_click(view, event) {
210-
// Click on the exit button.
211-
if (this.hoverExitButton) {
212-
if (event.button === 1)
213-
this._leave()
214-
return true
215-
}
216-
217161
// Click on the channel item.
218162
if (event.button === 1) {
219163
// Left click to open channel.
220164
this.parent.selectChannelItem(this)
221165
} else { // for GTK+ button could be 3 for trackpad right click.
222166
// Right click to show context menu.
223167
if (!this.menu) {
224-
if (this.channel.type === 'channel') {
225-
this.menu = gui.Menu.create([
226-
{ label: 'Popup to new window', onClick: this._popup.bind(this) },
227-
{ label: 'Leave channel', onClick: this._leave.bind(this) },
228-
])
229-
} else {
230-
this.menu = gui.Menu.create([
231-
{ label: 'Popup to new window', onClick: this._popup.bind(this) },
232-
])
233-
}
168+
const leaveLabel = this.channel.type === 'channel' ? 'Leave channel'
169+
: 'Close direct message'
170+
this.menu = gui.Menu.create([
171+
{ label: 'Popup to new window', onClick: this._popup.bind(this) },
172+
{ label: leaveLabel, onClick: this._leave.bind(this) },
173+
])
234174
}
235175
this.menu.popup()
236176
}

0 commit comments

Comments
 (0)