we have to be able to deal with longpoll error data returned not in an array, so make it look like an array if it's an error

This commit is contained in:
Andy Janata 2012-01-06 16:49:43 -08:00
parent eba02a35bd
commit c66c08cd4f
1 changed files with 11 additions and 2 deletions

View File

@ -33,8 +33,17 @@ cah.longpoll.complete = function() {
cah.longpoll.done = function(data_list) { cah.longpoll.done = function(data_list) {
cah.log.debug("long poll done", data_list); cah.log.debug("long poll done", data_list);
for ( var index in data_list) { var data_list_work;
var data = data_list[index]; // we need to handle non-array data, too, so just make it look like an array
if (data_list['error']) {
data_list_work = {};
data_list_work[0] = data_list;
} else {
data_list_work = data_list;
}
for ( var index in data_list_work) {
var data = data_list_work[index];
if (data['error']) { if (data['error']) {
// TODO cancel any timers or whatever we may have, and disable interface // TODO cancel any timers or whatever we may have, and disable interface
// this probably should be done in the appropriate error code handler because we may not // this probably should be done in the appropriate error code handler because we may not