image subscriptions was not always properly unsubscribing; fixed
This commit is contained in:
parent
42827362b6
commit
5f48dd0f0e
1 changed files with 23 additions and 22 deletions
|
@ -1126,7 +1126,8 @@ function Wardrobe() {
|
||||||
log("Outfit image still enqueued; will try again soon", outfit);
|
log("Outfit image still enqueued; will try again soon", outfit);
|
||||||
setTimeout(function () { checkSubscription(outfit) }, DELAY);
|
setTimeout(function () { checkSubscription(outfit) }, DELAY);
|
||||||
} else {
|
} else {
|
||||||
controller.unsubscribe(outfit);
|
// Unsubscribe everyone from this outfit and fire ready events
|
||||||
|
delete outfitSubscriptionTotals[outfit.id];
|
||||||
controller.events.trigger('imageReady', outfit);
|
controller.events.trigger('imageReady', outfit);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1137,31 +1138,31 @@ function Wardrobe() {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.subscribe = function (outfit) {
|
this.subscribe = function (outfit) {
|
||||||
if(outfit.id in outfitSubscriptionTotals) {
|
if(outfit.image_enqueued) {
|
||||||
// The subscription is already running. Just mark that one more
|
if(outfit.id in outfitSubscriptionTotals) {
|
||||||
// consumer is interested in it, and they'll all get a response soon.
|
// The subscription is already running. Just mark that one more
|
||||||
outfitSubscriptionTotals[outfit.id] += 1;
|
// consumer is interested in it, and they'll all get a response soon.
|
||||||
} else {
|
outfitSubscriptionTotals[outfit.id] += 1;
|
||||||
// This is a new subscription!
|
|
||||||
outfitSubscriptionTotals[outfit.id] = 1;
|
|
||||||
|
|
||||||
if(outfit.image_enqueued) {
|
|
||||||
// If the image is enqueued, trigger that event and start checking.
|
|
||||||
controller.events.trigger('imageEnqueued', outfit);
|
|
||||||
checkSubscription(outfit);
|
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, never bother checking: skip straight to the ready phase.
|
// This is a new subscription! Let's start checking it.
|
||||||
// Give it an instant timeout so that we're sure the consumer is ready
|
outfitSubscriptionTotals[outfit.id] = 1;
|
||||||
// for the event. (It can be tricky when the consumer assigns this
|
checkSubscription(outfit);
|
||||||
// return value somewhere to know if it cares about the event, so the
|
|
||||||
// event can't fire before the return.)
|
|
||||||
setTimeout(function () {
|
|
||||||
controller.events.trigger('imageReady', outfit)
|
|
||||||
}, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return outfit;
|
// Regardless, trigger the enqueued event for the new consumer's sake.
|
||||||
|
controller.events.trigger('imageEnqueued', outfit);
|
||||||
|
} else {
|
||||||
|
// Otherwise, never bother checking: skip straight to the ready phase.
|
||||||
|
// Give it an instant timeout so that we're sure the consumer is ready
|
||||||
|
// for the event. (It can be tricky when the consumer assigns this
|
||||||
|
// return value somewhere to know if it cares about the event, so the
|
||||||
|
// event can't fire before the return.)
|
||||||
|
setTimeout(function () {
|
||||||
|
controller.events.trigger('imageReady', outfit)
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return outfit;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.unsubscribe = function (outfit) {
|
this.unsubscribe = function (outfit) {
|
||||||
|
|
Loading…
Reference in a new issue