-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(interim, toast): add hide queue to prevent multiple interims at same time #6684
Conversation
@@ -291,6 +291,12 @@ function InterimElementProvider() { | |||
// This hide()s only the current interim element before showing the next, new one | |||
// NOTE: this is not reversible (e.g. interim elements are not stackable) | |||
|
|||
if (!hideExisting) { | |||
return $q(function(resolve, reject) { | |||
reject("Too many interim elements in queue!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about the rejection, but that's the best way to prevent the interim element to stuck on showing. Any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return $q.reject('Too many interim elements in queue!');
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, definitely better!
cant get your point |
@GongT - I think you just didn't read the complete code. I will talk through the steps with you... In this PR, we only remove the element from the stack if the hide is completed. |
var promise = $q.all(stack.reverse().map(closeElement)); | ||
stack = []; | ||
return promise; | ||
return $q.all(stack.reverse().map(closeElement)); | ||
} else if (options.closeTo !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you fix it to be just options.closeTo
also the else statement is redundant because we return value from the last if statement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, but I don't get what you mean with the else statement?
if (options.closeAll) {
return $q.all(stack.reverse().map(closeElement));
} else if (options.closeTo) {
return $q.all(stack.slice(options.closeTo).map(closeElement));
} else {
return closeElement(stack[hideQueue]);
}
Every check will be used. Mostly this return closeElement(stack[hideQueue]);
when showing / hiding a toast
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what i meant is some thing like this:
if (options.closeAll) {
return $q.all(stack.reverse().map(closeElement));
}
if (options.closeTo) {
return $q.all(stack.slice(options.closeTo).map(closeElement));
}
return closeElement(stack[hideQueue]);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh got it 😄 Done!
8c151f3
to
99d90ab
Compare
After this patch, the interim stack will pick up the first added element from the stack which is not in hide process. At the moment we always take the first added (not caring about current hide process). Also the stack always removes the elements immediately, which causes errors when showing multiple interims (for example spamming toasts). After this fix, we will remove the elements after the hide-process is done (like a stack queue) Fixes angular#6633 Fixes angular#4822
99d90ab
to
6ce97aa
Compare
@EladBezalel - Updated the description of the PR (also waiting for #7053 for being merged). Just made this PR compatible with the new changes from #7053.
|
Closing this, because I will improve that, when we starting to support multiple dialogs. That means, we need to take a more accurate look at the interim element stack. |
After this patch, the interim stack will pick up the first added element from the stack which
is not in hide process. At the moment we always take the first added (not caring about current hide process).
Also the stack always removes the elements immediately, which causes errors when showing multiple interims (for example spamming toasts). After this fix, we will remove the elements after the hide-process is done (like a stack queue)
Fixes #6633 Fixes #8111 Fixes #4822