Remove isExecuting check in Toast.finish#123
Merged
Merged
Conversation
Contributor
Author
|
@devxoul Let me know if there's anything I can do to help you review this PR. Thanks! |
Owner
|
Oh sorry, I'm not having enough time to review this PR and other issues. I'm planning to rewrite the Toaster library to have tests and a solid architecture. By the way I believe that this PR would work properly so I'm gonna merge this and make a new release soon. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #111
This reverts #109 and subsequently will impact this issue: #107.
As of Toaster 2.0.4
Toast.finish()skips settingisFinished=trueandisExecuting=falsewhen the operation is not executing. This causes an issue where callingcancel()right aftershow()will cause the operation queue to stall.On the same vibe, since
ToastCenter.currentToastdidn't exclude cancelled and finished tasks, callingcancel()right aftershow()would causecurrentToastto not be nil.What's the bug
Since
show()adds the operation to a background queue, it meansToast.startactually postpones thestart()which causescancel()to be called beforestart().According to the
cancel()docs:So
cancel()needs to setisFinished=trueandisExecuting=false. However in #109 we added a check that would prevent setting those flags if the operation is not executing. Since we're not setting those flags properly, the operation queue will callstart()and wait for the operation to complete. However the operation will never complete because we ignore the start call if the operation is cancelled (see below).Furthermore, according to
start()'s documentation, we need to ignore finished/executing/cancelled operations because we're overriding the default implementation ofstart()which was performing those checks for us:The fix
Removed the
isExecutingguard inToast.finish()Removed a
super.start()call since the docs specify that it must not be calledInstead, we're calling
main()fromstart()directly.Since
ToastCenter.currentToastwould return finished/cancelled operations, I fixed it by filtering those outAdded basic unit tests to make sure those issues are fixed, as well as one basic test that introspects the shared window.
Let me know if you have any question!