diff --git a/internal_packages/keybase/lib/keybase-search.cjsx b/internal_packages/keybase/lib/keybase-search.cjsx
index 2a6101b19..c4dba6006 100755
--- a/internal_packages/keybase/lib/keybase-search.cjsx
+++ b/internal_packages/keybase/lib/keybase-search.cjsx
@@ -1,4 +1,11 @@
-{Utils, React, ReactDOM, Actions, RegExpUtils} = require 'nylas-exports'
+{Utils,
+ React,
+ ReactDOM,
+ Actions,
+ RegExpUtils,
+ IdentityStore,
+ AccountStore,
+ EdgehillAPI} = require 'nylas-exports'
{RetinaImg} = require 'nylas-component-kit'
EmailPopover = require './email-popover'
PGPKeyStore = require './pgp-key-store'
@@ -7,6 +14,46 @@ Identity = require './identity'
kb = require './keybase'
_ = require 'underscore'
+class KeybaseInviteButton extends React.Component
+
+ constructor: (@props) ->
+ @state = {
+ loading: false,
+ }
+
+ _onGetKeybaseInvite: =>
+ @setState({loading: true})
+
+ token = AccountStore.tokenForAccountId(AccountStore.accounts()[0].id)
+ errorHandler = (err) =>
+ @setState({loading: false})
+ NylasEnv.showErrorDialog(err.message)
+
+ EdgehillAPI.makeRequest
+ auth:
+ user: token
+ pass: ""
+ path: "/keybase-invite",
+ method: "POST",
+ body:
+ n1_id: IdentityStore.identityId(),
+ error: errorHandler,
+ success: (body, response) =>
+ @setState({loading: false})
+ try
+ {invite_url} = JSON.parse(body)
+ if not invite_url
+ throw new Error("We were unable to retrieve an invitation.")
+ catch err
+ errorHandler(err)
+ require('electron').shell.openExternal(invite_url)
+
+ render: =>
+ if @state.loading
+ Processing...
+ else
+ We've got an invite for you!
+
module.exports =
class KeybaseSearch extends React.Component
@displayName: 'KeybaseSearch'
@@ -17,10 +64,12 @@ class KeybaseSearch extends React.Component
# clicked instead of the "please specify an email" popover
importFunc: React.PropTypes.function
# TODO consider just passing in a pre-specified email instead of a func?
+ inPreferences: React.PropTypes.bool
@defaultProps:
initialSearch: ""
importFunc: false
+ inPreferences: false
constructor: (props) ->
super(props)
@@ -115,22 +164,25 @@ class KeybaseSearch extends React.Component
if not profiles? or profiles.length < 1
profiles = []
+ badSearch = null
+ loading = null
+ empty = null
+
if profiles.length < 1 and @state.searchedByEmail
- badSearch = Keybase cannot be searched by email address.
Try entering a name or Keybase username.
- else
- badSearch = false
+ badSearch = Keybase cannot be searched by email address.
Try entering a name, or a username from GitHub, Keybase or Twitter.
if @state.loading
loading =
Not a Keybase user yet?