Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Merge pull request #47 from learn-co/wait-to-activate
Browse files Browse the repository at this point in the history
Only activate after primary package has completed activation
  • Loading branch information
drewprice authored May 12, 2017
2 parents 15d0606 + 37cc3cd commit 2923404
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
8 changes: 7 additions & 1 deletion lib/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ FileIcons = require './file-icons'

nsync = require 'nsync-fs'
nsyncInitializer = require './nsync/initializer'
{primaryLearnIDEPackage} = require '../package.json'

module.exports =
treeView: null

activate: (@state) ->
activate: (state) ->
primaryPkg = atom.packages.loadPackage(primaryLearnIDEPackage)
primaryPkg.activate().then =>
@activateLearnIdeTree(state)

activateLearnIdeTree: (@state) ->
@nsyncDisposables = nsyncInitializer(@state)

@warnIfAtomsTreeViewIsActive()
Expand Down
4 changes: 4 additions & 0 deletions lib/nsync/atom-helper.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ module.exports = helper =
if value?
resolve(value)

waitForTerminalConnection: ->
pkg = atom.packages.loadPackage(primaryLearnIDEPackage)
pkg.mainModule.getTermConnectionPromise()

learnIdeVersion: ->
if not LEARN_IDE_VERSION?
pkg = atom.packages.loadPackage(primaryLearnIDEPackage)
Expand Down
13 changes: 7 additions & 6 deletions lib/nsync/initializer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,13 @@ module.exports = helper = (activationState) ->

disposables.forEach (disposable) -> composite.add(disposable)

atomHelper.getToken().then (token) ->
nsync.configure
expansionState: activationState.directoryExpansionStates
localRoot: _path.join(atom.configDirPath, '.learn-ide')
connection:
url: "#{WS_SERVER_URL}?token=#{token}&version=#{atomHelper.learnIdeVersion()}"
atomHelper.waitForTerminalConnection().then ->
atomHelper.getToken().then (token) ->
nsync.configure
expansionState: activationState.directoryExpansionStates
localRoot: _path.join(atom.configDirPath, '.learn-ide')
connection:
url: "#{WS_SERVER_URL}?token=#{token}&version=#{atomHelper.learnIdeVersion()}"

return composite

0 comments on commit 2923404

Please sign in to comment.