Survive clearing of localStorage while we're running by caching client ID.

This commit is contained in:
Ian Gulliver
2014-06-13 21:33:19 -07:00
parent 40229ff0c0
commit 7d45f44265

View File

@@ -99,6 +99,11 @@ var Cosmopolite = function(
if (!localStorage[this.namespace_ + ':client_id']) {
localStorage[this.namespace_ + ':client_id'] = this.uuid_();
}
/**
* @type {string}
* @private
*/
this.clientID_ = localStorage[this.namespace_ + ':client_id'];
/**
* @type {string}
@@ -710,7 +715,8 @@ Cosmopolite.prototype.onReceiveMessage_ = function(data) {
}
break;
case 'logout_complete':
localStorage[this.namespace_ + ':client_id'] = this.uuid_();
this.clientID_ = localStorage[this.namespace_ + ':client_id'] =
this.uuid_();
localStorage.removeItem(this.namespace_ + ':google_user_id');
if (this.socket_) {
this.socket_.close();
@@ -820,7 +826,7 @@ Cosmopolite.prototype.sendRPCs_ = function(commands, opt_delay) {
}
var request = {
'instance_id': this.instanceID_,
'client_id': localStorage[this.namespace_ + ':client_id'],
'client_id': this.clientID_,
'commands': []
};
commands.forEach(function(command) {