-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix(InAppNotifications): use timer to detect notification dismiss event after timeout #1434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(InAppNotifications): use timer to detect notification dismiss event after timeout #1434
Conversation
|
Wondering if it would make sense to do this with a timer instead that you simply cancel when it's dismissed before the timer runs out? |
|
@nmetulev yeah, that's what I had suggested too. |
|
@michael-hawker Sorry, I forgot your comment on this. It is a better solution indeed. Thanks. |
|
I like this better too. Could you also update the documentation with the change of the method? |
|
@nmetulev Sorry. Good catch. |
michael-hawker
left a comment
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.
This is great! Just one small code ordering/timing issue + doc updates like @nmetulev said.
| { | ||
| await Task.Delay(duration); | ||
| Dismiss(); | ||
| _timer.Stop(); |
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.
You should move all this timer stop code to be first to ensure the timer doesn't fire between when you call the make visible state and stopping the timer.
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.
Even better.
michael-hawker
left a comment
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.
You left the 'await's at the start everywhere...
docs/controls/InAppNotification.md
Outdated
| if (isTemplatePresent && inAppNotificationWithButtonsTemplate is DataTemplate) | ||
| { | ||
| await ExampleInAppNotification.ShowAsync(inAppNotificationWithButtonsTemplate as DataTemplate); | ||
| await ExampleInAppNotification.Show(inAppNotificationWithButtonsTemplate as DataTemplate); |
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.
Don't forget to remove the await here.
docs/controls/InAppNotification.md
Outdated
|
|
||
| ```c# | ||
| await ExampleInAppNotification.ShowAsync("Some text.", 2000); // the notification will appear for 2 seconds | ||
| await ExampleInAppNotification.Show("Some text.", 2000); // the notification will appear for 2 seconds |
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.
and here.
michael-hawker
left a comment
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 for the quick turnarounds on this!
fix #1415
@bkaankose I tried to use CancellationToken but it added so much code and it is seemed a little messy to me. The unique id do the trick but yes the Task.Delay is not cancelled immediately...