Created
October 21, 2011 05:53
-
-
Save jhurliman/1303191 to your computer and use it in GitHub Desktop.
Add a custom timeout to FB.getLoginStatus()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Add this somewhere after FB.init() and before any calls to FB.getLoginStatus() */ | |
// Add a timeout to FB.getLoginStatus() | |
var FB_STATUS_TIMEOUT = 1000 * 30; | |
var origGetLoginStatus = FB.getLoginStatus; | |
FB.getLoginStatus = function(callback, force) { | |
// Start a timer | |
var timedOut = false; | |
var timeout = setTimeout(function() { | |
timedOut = true; | |
if (callback) callback({ error: 'timeout' }); | |
}, FB_STATUS_TIMEOUT); | |
// Call the real FB.getLoginStatus() | |
origGetLoginStatus(function(response) { | |
if (!timedOut) { | |
clearTimeout(timeout); | |
if (callback) callback(response); | |
} | |
}, force); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment