Skip to content
This repository has been archived by the owner on Dec 13, 2017. It is now read-only.

Commit

Permalink
Only attempt to open a new chat if one isn't found.
Browse files Browse the repository at this point in the history
Closes #21.
  • Loading branch information
cjsaylor committed Apr 24, 2015
1 parent 2e2c59f commit 4d070cc
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions lib/irc.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,29 @@ module.exports =

@subscriptions = new CompositeDisposable
@subscriptions.add atom.commands.add 'atom-workspace', 'irc:toggle', =>
atom.workspace.open('irc://chat', split: 'right').then (ircView) =>
ircView
.focusInput()
.scrollToEnd()
pane = @findOpenPane()
if pane
pane.focus()
pane.focusInput().scrollToEnd()
else
atom.workspace.open('irc://chat', split: 'right', searchAllPanes: true).then (ircView) ->
ircView
.focusInput()
.scrollToEnd()
@subscriptions.add atom.commands.add 'atom-workspace', 'irc:connect', =>
@client.connect()
@subscriptions.add atom.commands.add 'atom-workspace', 'irc:disconnect', =>
@client.disconnect()
@subscriptions.add atom.config.onDidChange 'irc', =>
@initializeIrc true

findOpenPane: ->
matched = false
atom.workspace.getPaneItems().forEach (pane) ->
if pane instanceof IrcView
matched = pane
matched

deactivate: ->
@ircStatusView.destroy()
@ircView.destroy()
Expand Down

0 comments on commit 4d070cc

Please sign in to comment.