forked from OpenNeo/impress
fix some outfits list bugs
I think I got the 0-width bug where the outfit never expands beyond 0px width, and there were also some issues with the fact that image subscriptions pointed to the current outfit object, even after that object had changed identity, so now we re-fetch from the cache by ID.
This commit is contained in:
parent
ec40e6ae67
commit
4dd2bc9549
2 changed files with 20 additions and 17 deletions
|
@ -550,7 +550,7 @@ View.Outfits = function (wardrobe) {
|
||||||
|
|
||||||
wardrobe.outfits.bind('addOutfit', function (outfit, i) {
|
wardrobe.outfits.bind('addOutfit', function (outfit, i) {
|
||||||
var next_child = outfits_list_el.children().not('.hiding').eq(i),
|
var next_child = outfits_list_el.children().not('.hiding').eq(i),
|
||||||
outfit_el = $.tmpl('outfitTemplate', outfit);
|
outfit_el = $.tmpl('outfitTemplate', outfit.clone());
|
||||||
if(next_child.length) {
|
if(next_child.length) {
|
||||||
outfit_el.insertBefore(next_child);
|
outfit_el.insertBefore(next_child);
|
||||||
} else {
|
} else {
|
||||||
|
@ -558,8 +558,8 @@ View.Outfits = function (wardrobe) {
|
||||||
}
|
}
|
||||||
updateActiveOutfit();
|
updateActiveOutfit();
|
||||||
|
|
||||||
var naturalWidth = outfit_el.width();
|
var naturalWidth = outfit_el.css('width');
|
||||||
log("Natural width is", naturalWidth);
|
log("Natural width is", naturalWidth, outfit_el.width());
|
||||||
outfit_el.width(0).animate({width: naturalWidth}, 'normal');
|
outfit_el.width(0).animate({width: naturalWidth}, 'normal');
|
||||||
listSubscribeToImage(outfit);
|
listSubscribeToImage(outfit);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1119,21 +1119,24 @@ function Wardrobe() {
|
||||||
var DELAY = 5000;
|
var DELAY = 5000;
|
||||||
var controller = this;
|
var controller = this;
|
||||||
|
|
||||||
function checkSubscription(outfit) {
|
function checkSubscription(outfit_id) {
|
||||||
outfit.reload(function () {
|
Outfit.find(outfit_id, function (outfit) {
|
||||||
if(outfitSubscriptionTotals[outfit.id] > 0) {
|
log("Checking image for", outfit);
|
||||||
if(outfit.image_enqueued) {
|
outfit.reload(function () {
|
||||||
log("Outfit image still enqueued; will try again soon", outfit);
|
if(outfitSubscriptionTotals[outfit_id] > 0) {
|
||||||
setTimeout(function () { checkSubscription(outfit) }, DELAY);
|
if(outfit.image_enqueued) {
|
||||||
|
log("Outfit image still enqueued; will try again soon", outfit);
|
||||||
|
setTimeout(function () { checkSubscription(outfit_id) }, DELAY);
|
||||||
|
} else {
|
||||||
|
// Unsubscribe everyone from this outfit and fire ready events
|
||||||
|
delete outfitSubscriptionTotals[outfit_id];
|
||||||
|
controller.events.trigger('imageReady', outfit);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Unsubscribe everyone from this outfit and fire ready events
|
log("Outfit was unsubscribed", outfit);
|
||||||
delete outfitSubscriptionTotals[outfit.id];
|
delete outfitSubscriptionTotals[outfit_id];
|
||||||
controller.events.trigger('imageReady', outfit);
|
|
||||||
}
|
}
|
||||||
} else {
|
});
|
||||||
log("Outfit was unsubscribed", outfit);
|
|
||||||
delete outfitSubscriptionTotals[outfit.id];
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1146,7 +1149,7 @@ function Wardrobe() {
|
||||||
} else {
|
} else {
|
||||||
// This is a new subscription! Let's start checking it.
|
// This is a new subscription! Let's start checking it.
|
||||||
outfitSubscriptionTotals[outfit.id] = 1;
|
outfitSubscriptionTotals[outfit.id] = 1;
|
||||||
checkSubscription(outfit);
|
checkSubscription(outfit.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regardless, trigger the enqueued event for the new consumer's sake.
|
// Regardless, trigger the enqueued event for the new consumer's sake.
|
||||||
|
|
Loading…
Reference in a new issue