Skip to content
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

Merge replacing and displaying into showing #126

Merged
merged 3 commits into from
Mar 1, 2018
Merged

Merge replacing and displaying into showing #126

merged 3 commits into from
Mar 1, 2018

Conversation

annevk
Copy link
Member

@annevk annevk commented Feb 28, 2018

This gives a more consistent story for event dispatching. The former setup was especially buggy if native replacement is not supported.

This also reduces duplication (such as waiting for fetches).

And it queues a task for the show and close events.


Preview | Diff

@annevk annevk requested a review from beverloo February 28, 2018 11:33
Copy link
Member

@beverloo beverloo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's one race condition, other than that this is great -- thanks!

notifications.bs Outdated
set, <a for=/>fetch</a> <var>notification</var>'s <a for=notification>sound URL</a> if it has
been set.
<p>If the notification platform supports sounds, and either <var>notification</var>'s
<a for=notification>old notification</a> is or <var>notification</var>'s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove "is", or change it to "is set"?

notifications.bs Outdated

<ol>
<li><p><a>Handle close events</a> with <var>notification</var>'s
<a for=notification>old notification</a>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since old notification is set immediately, but these steps are run in parallel, doesn't this now imply that the following snippet would result in the close event on n being fired twice?

const n = new Notification('foo', { tag: 'a' });
n.addEventListener('show', () => {
  new Notification('bar', { tag: 'a' });
  new Notification('baz', { tag: 'a' });
});

I guess we can either add a closing flag that's set immediately, or add some logic to ensure that the close steps are not run twice for a particular notification?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I think that once #127 lands I could rebase and rewrite this bit to query the old notification during showing. That should remove this issue and leave less state on notifications.

The only thing that remains to fully remove all race conditions is to use a "parallel queue" to ensure that the "in parallel" steps don't race with each other. I need to file a follow-up on that.

This gives a more consistent story for event dispatching. The former setup was especially buggy if native replacement is not supported.

This also reduces duplication (such as waiting for fetches).

And it queues a task for the show and close events.
@annevk
Copy link
Member Author

annevk commented Feb 28, 2018

I rebased this on top of the sound removal and thereby addressed the race issue (I hope). I filed #128 as a follow-up to formalize even more.

notifications.bs Outdated
<a>notification</a> and <var>notification</var>.
<li><p>Wait for any <a for=/ lt=fetch>fetches</a> to complete and <var>notification</var>'s
<a for=notification>image resource</a> <a for=notification>icon resource</a>,
<a for=notification>badge resource</a>, and <a for=notification>sound resource</a> to be set
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no more sound resource

notifications.bs Outdated
@@ -70,7 +70,7 @@ run.

<p>A <a>notification</a> has an associated
<dfn for=notification id=silent-preference-flag>silent preference flag</dfn> which is initially
unset. When set indicates that no sounds or vibrations should be made.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept this in because the user agent could still suppress any default sounds the platform's notification center may make, which feels appropriate for a property called silent.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good call.

@annevk annevk merged commit e9407eb into master Mar 1, 2018
@annevk annevk deleted the annevk/tasks branch March 1, 2018 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants