Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed prefs bug.

  • Loading branch information...
commit cc0613138bc169eab250c229afe92bc282153801 1 parent 37925d1
@mackers mackers authored
Showing with 26 additions and 14 deletions.
  1. +12 −7 components/facebook.js
  2. +14 −7 components/fbRemoteAutoComplete.js
View
19 components/facebook.js
@@ -528,6 +528,7 @@ facebookService.prototype = {
},
sessionStartOAuth: function(accessToken) {
+ accessToken = "" + accessToken.toString();
debug('sessionStartOAuth: ' + accessToken);
this._accessToken = accessToken;
@@ -541,12 +542,10 @@ facebookService.prototype = {
debug("XX SAVING ACCESS TOKEN: " + accessToken);
//debug("XX SAVING UID: " + response.id);
- fbSvc._uid = response.id;
+ fbSvc._uid = "" + response.id.toString();
fbSvc._loggedIn = true;
- fbSvc._prefService.setCharPref('extensions.facebook.access_token', accessToken)
- fbSvc._prefService.setCharPref('extensions.facebook.uid', response.id)
-
- debug("XX ACCESS TOKEN PREF NOW: " + fbSvc._prefService.getCharPref('extensions.facebook.access_token'));
+ fbSvc._prefService.setCharPref('extensions.facebook.access_token', accessToken);
+ fbSvc._prefService.setCharPref('extensions.facebook.uid', fbSvc._uid);
}
else
{
@@ -585,7 +584,10 @@ facebookService.prototype = {
// persist API sessions across the Firefox shutdown
// by saving them in the password store
if (this._uid)
+ {
+ debug("XX saving uid");
this.savePref( 'extensions.facebook.uid', this._uid );
+ }
var hostname = PASSWORD_URL;
var formSubmitURL = PASSWORD_URL;
@@ -635,8 +637,11 @@ facebookService.prototype = {
debug('sessionEnd');
// remove session info from prefs because of explicit logout
// or because they didn't work
- this.savePref( 'extensions.facebook.uid', '' );
- this.savePref( 'extensions.facebook.access_token', '' );
+ debug('XX RESETTING ACCESS PREFS');
+ this._prefService.unlockPref('extensions.facebook.uid');
+ this._prefService.clearUserPref('extensions.facebook.uid');
+ this._prefService.unlockPref('extensions.facebook.access_token');
+ this._prefService.clearUserPref('extensions.facebook.access_token');
Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService)
View
21 components/fbRemoteAutoComplete.js
@@ -12,9 +12,13 @@ const FB_UID_PREF = "extensions.facebook.uid";
const FB_BOOTSTRAP_ENDPOINT = "https://www.facebook.com/ajax/typeahead/search/bootstrap.php";
const FB_QUERY_ENDPOINT = "https://www.facebook.com/ajax/typeahead/search.php";
+var aConsoleService = Components.classes["@mozilla.org/consoleservice;1"].
+ getService(Components.interfaces.nsIConsoleService);
+
var debug = function(msg)
{
dump("fbRemoteAutoComplete: " + msg + "\n");
+ aConsoleService.logStringMessage("fbRemoteAutoComplete: " + msg);
}
function XMLHttpRequest()
@@ -355,11 +359,11 @@ FacebookRemoteAutoCompleteSearch.prototype = {
{
var queryResults = self.parsePayload(self.queryRequest.responseText.substr(9));
- //debug("XX finished ajax query for '" + searchString + "'");
+ debug("XX finished ajax query for '" + searchString + "'");
if (queryResults)
{
- //debug("XX some results from that ");
+ debug("XX adding " + cachedResults.matchCount + " cached results to query results");
if (cachedResults && cachedResults.matchCount > 0)
{
@@ -392,6 +396,7 @@ FacebookRemoteAutoCompleteSearch.prototype = {
}
else
{
+ debug("XX have a query result '" + queryResults[id].text + "'");
newResult.appendMatch(
queryResults[id].path,
queryResults[id].text,
@@ -527,11 +532,11 @@ FacebookRemoteAutoCompleteSearch.prototype = {
var tmpResults = searchACache(search_lc, this.resultCache);
tmpResults = tmpResults.sort(function(a, b) { return a.index - b.index; });
- //debug("XX have " + tmpResults.length + " result from bootstrap cache matches");
+ debug("XX have " + tmpResults.length + " results from bootstrap cache ");
if (this.queryCache[search_lc])
{
- //debug("XX found cached query for '" + search_lc + "'");
+ debug("XX found cached query for '" + search_lc + "'");
newResult.hitQueryCache = true;
//tmpResults = tmpResults.concat(searchACache(search_lc, this.queryCache[search_lc]));
@@ -552,7 +557,7 @@ FacebookRemoteAutoCompleteSearch.prototype = {
tmpResults.push(this.queryCache[search_lc][id]);
}
- //debug("XX have " + tmpResults.length + " results from bootstrap cache matches + query cache matches");
+ debug("XX have " + tmpResults.length + " results from bootstrap cache matches + query cache matches");
}
if (tmpResults.length > 0)
@@ -625,8 +630,6 @@ FacebookRemoteAutoCompleteSearch.prototype = {
var res = this.searchResultCache(searchString);
- debug("results found in cache = " + res.matchCount);
-
if (self.queryTimeout)
{
try
@@ -640,10 +643,14 @@ FacebookRemoteAutoCompleteSearch.prototype = {
if (res.matchCount > 5 || res.hitQueryCache)
{
//this._lastResult = res;
+ debug("results found in cache = " + res.matchCount + " , will show results now");
+
return listener.onSearchResult(this, res);
}
else
{
+ debug("results found in cache = " + res.matchCount + " , will fetch more results");
+
var event = {
notify: function(timer) {
self.query(searchString, res, listener);
Please sign in to comment.
Something went wrong with that request. Please try again.