Allow preventDefault to be fired up to two times#2138
Merged
Conversation
* The preventDefault(discard) method can now be called up to two times with false and then true. * This is necessary for the `NotificationWillDisplayEvent` for wrappers which may need to call this twice, once to capture the event internally and once from the developer's intent. * For consistency, this ability is added to the `NotificationReceivedEvent` as well.
* There is a lot of duplicated setup code, so let's extract common ones into a helper class * There are no logic changes in this commit.
preventDefault to be fired up to two timespreventDefault to be fired up to two times
* The tests ensure calling preventDefault twice work when called in different threads * And a followup call to display does not display the notification
7d4391d to
9b7b91d
Compare
jennantilla
approved these changes
Jul 10, 2024
jkasten2
approved these changes
Jul 11, 2024
Contributor
Author
|
|
jkasten2
approved these changes
Jul 18, 2024
Merged
This was referenced Aug 15, 2024
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.
Description
One Line Summary
Allow
preventDefaultto be fired up to two times with thediscardparameter offalseand thentrue, for the Received Event and the Display Event.Details
discardparameter is read when the callback returns. Then the logic continues on with that state.preventDefault(true)had no effect.preventDefault(false)can be called multiple times and has no effects due to no state change.Motivation
To allow #2094 to work for wrappers.
Scope
Calling preventDefault twice where the first does not discard and the second discards.
Testing
Unit testing
Manual testing
NotificationLifecycleListenerfor the will display event.preventDefault()preventDefault(true)display()NotificationServiceExtensionfor the received event.Also test there is no breaking of current behavior when preventDefault(discard: false) is called followed by display, will display the notification.
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is