Send profile with every RPC response.

This commit is contained in:
Ian Gulliver
2014-06-17 21:14:59 -07:00
parent a1ee25a937
commit c210d826b2
2 changed files with 12 additions and 14 deletions

View File

@@ -172,7 +172,6 @@ Cosmopolite.typeEvent_;
/**
* @typedef {{event_type: string,
* profile: string,
* google_user: string}}
* @private
*/
@@ -180,8 +179,7 @@ Cosmopolite.typeLogin_;
/**
* @typedef {{event_type: string,
* profile: string}}
* @typedef {{event_type: string}}
* @private
*/
Cosmopolite.typeLogout_;
@@ -842,6 +840,14 @@ Cosmopolite.prototype.onRPCResponse_ =
return;
}
/** @type {string} */
this.profile_ = data['profile'];
this.trackEvent('set', 'userId', this.profile_);
var resolve;
while (resolve = this.profilePromises_.pop()) {
resolve(this.profile_);
}
for (var i = 0; i < data['responses'].length; i++) {
var response = data['responses'][i];
if (response['result'] == 'retry') {
@@ -1298,15 +1304,6 @@ Cosmopolite.prototype.onServerEvent_ = function(e) {
if (this.shutdown_) {
return;
}
if (e['profile']) {
/** @type {string} */
this.profile_ = e['profile'];
this.trackEvent('set', 'userId', this.profile_);
this.profilePromises_.forEach(function(resolve) {
resolve(this.profile_);
}, this);
this.profilePromises_.length = 0;
}
switch (e['event_type']) {
case 'close':
this.onClose_();