Skip to content

Commit

Permalink
Merge pull request Wizcorp#24 from thomashilzendegen/master
Browse files Browse the repository at this point in the history
Init of FB SDK in browser proxy
  • Loading branch information
jeduan committed Aug 24, 2015
2 parents c3af000 + a5966fd commit 3c5c8b8
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions www/facebook-browser.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/* global FB */
var isInited = false

// Bake in the JS SDK
insertSdk()

exports.getLoginStatus = function getLoginStatus (s, f) {
if (!assertInited()) return printError(f, new Error('init not called with valid version'))
FB.getLoginStatus(function (response) {
Expand Down Expand Up @@ -105,25 +102,21 @@ exports.browserInit = function (appId, version, s) {
// Global :(
// This function will be called by the FB SDK when the client is inited
window.fbAsyncInit = function fbAsyncInit () {
isInited = true
if (typeof s === 'function') s()
}

function _actualInit () {
version = version || 'v2.4'

FB.init({
appId: appId,
xfbml: false,
version: version
})

isInited = true

if (typeof s === 'function') s()
}

// deal with race condition of calling FB.init before loading the SDK
var interval = setInterval(function () {
if (!window.FB) return
clearInterval(interval)
_actualInit()
}, 200)
// Bake in the JS SDK
insertSdk()
}

function assertInited () {
Expand Down

0 comments on commit 3c5c8b8

Please sign in to comment.