Skip to content

Commit

Permalink
Merge pull request #19 from t9md/master
Browse files Browse the repository at this point in the history
Focus Atom application  when text-synced from chrome browser
  • Loading branch information
Daniel Perez authored Jul 27, 2017
2 parents 1b6a8f9 + 3bbf0cf commit 4608ef1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/atomic-chrome.coffee
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{CompositeDisposable} = require 'atom'
{Server} = require 'ws'

WSHandler = require './ws-handler'

{Server} = require 'ws'
WSHandler = null # defer require till necessary
WS_PORT = 64292

module.exports = AtomicChrome =
activate: (state) ->
@wss = new Server({port: WS_PORT})

@wss.on 'connection', (ws) ->
WSHandler ?= require './ws-handler'
new WSHandler(ws)
@wss.on 'error', (err) ->
console.error(err) unless err.code == 'EADDRINUSE'
Expand Down
1 change: 1 addition & 0 deletions lib/ws-handler.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = class WSHandler

register: (data) ->
filepath = @getFile(data)
atom.focus() # activivate Atom application
atom.workspace.open(filepath).then (editor) =>
@initEditor(editor, data)

Expand Down

0 comments on commit 4608ef1

Please sign in to comment.