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

Multiple icon definitions #76

Closed
wants to merge 3 commits into from
Closed

Multiple icon definitions #76

wants to merge 3 commits into from

Conversation

mvano
Copy link
Contributor

@mvano mvano commented Jun 1, 2016

I think the initial patch has the general shape of what I want to do for #28.

I did find there's two ways we could go with the attribute getters on a notification, for example for the icon. To me it's not clear whether we need a single icon getter that reflects the selected url, or both icon and icons which reflect the exact input from options.

Previously icon reflected a serialization of the options icon input that was parsed with baseURL, not the exact original input. That means, for example, that if parsing fails, the getter returns the empty string. The implications for NotificationIcon are not clear to me: would invalid input such as for type or sizes need to be dropped in the same way? That might surprise developers.


Preview | Diff

notifications.bs Outdated

<li><p>For each <var>icon</var> in <var>icons</var> run these substeps:

<ol>
Copy link
Member

Choose a reason for hiding this comment

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

I know we have this indentation elsewhere, but if the <p> is not the sole child of an <li> it really should go on its own line and get indented. And this <ol> too.

@annevk
Copy link
Member

annevk commented Jun 7, 2016

I think it would be nicer if icon/badge simply reflected the selected URL.

@annevk
Copy link
Member

annevk commented Jun 7, 2016

(And we'd do away with icons/badges.)

@mvano
Copy link
Contributor Author

mvano commented Jun 8, 2016

Thanks Anne, I've cleaned it up a bit as discussed. Of note:

  • Just return the selected URL, do not expose getters for the multiple inputs.
  • As input and output are now more obviously asymmetrical (the missing getters on the output) I had to split NotificationAction into a NotificationActionOptions dictionary and a NotificationAction interface.
  • Afaict using an interface with readonly attributes for the output has the happy side effect of not needing to explicitly freeze the action, so I deleted that wrinkle.

notifications.bs Outdated
<ol>
<li><p>Let <var>selectedURL</var> and <var>selectedIcon</var> be null.

<li><p>For each <var>icon</var> in <var>icons</var> run these substeps:
Copy link
Member

Choose a reason for hiding this comment

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

<p> needs to be on a new line.

@annevk
Copy link
Member

annevk commented Jun 8, 2016

This looks pretty good I think. Who else should we ask for review?

@mvano
Copy link
Contributor Author

mvano commented Jun 8, 2016

CC @beverloo @foolip @mounirlamouri @xxyzzzq in case there's something really crazy in here. If necessary we can probably align a detail or two as needed in a followup change.

@annevk
Copy link
Member

annevk commented Jun 8, 2016

I'll aim to land this Friday (maybe ping me during the day just in case) unless someone has major concerns.

@foolip
Copy link
Member

foolip commented Jun 8, 2016

There's definitely some similarity here with w3c/mediasession#129

Feedback on that PR appreciated, and is there a good place to put the common bits? Looks to me at first glace like the whole "list of images" concept that uses the [{src:'foo'}] syntax can and should be shared.

notifications.bs Outdated
immutable. But FrozenArray reifies the dictionaries to mutable JS
objects accessed by reference, so we explicitly freeze them.
It would be better to do this with IDL primitives instead of JS - see
https://www.w3.org/Bugs/Public/show_bug.cgi?id=29004 -->
Copy link
Member

Choose a reason for hiding this comment

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

What's the conclusion of this? Looks like the issue was side-stepped by not exposing an icons member on NotificationAction, is that a permanent situation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only exposing the selected URL seems much easier to understand. I don't see a strong use case for reflecting all the exact input of the options dictionaries, so I don't expect us to add that. Note that we already didn't expose the exact input of the icon urls, we reflected the result of resolving with baseURL.

Also, by using an interface with readonly attributes, I don't think we need to freeze the object anymore, which was a strange wrinkle.

Copy link
Member

Choose a reason for hiding this comment

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

So is the resource chosen synchronously so that it can be immediately reflected through a single icon attribute? Doesn't that mean that the bits implementing the notification API need to know quite a bit about the UI of the platform its running on?

AFACIT, the thing that was frozen here wasn't the value returned by the attribute (which is readonly), but the NotificationAction objects in that array. Otherwise one can do things like notification.actions[0].icon = 'newicon.png' which would have no effect. Exact same problem as discussed for Media Session artwork, in other words.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question about synchronously reflecting the selected URL... that might require an async IPC message in Chrome. I'll have to think about that one.

The general solution to avoid having to freeze dictionaries seems to be to instead return interfaces with readonly attributes. NotificationAction now is an interface that only has readonly attributes, and assigning a new value to icon has no effect, intentionally. The property value does not change, and internally nothing changes. No exception is thrown.

@annevk
Copy link
Member

annevk commented Oct 11, 2022

Closing this due to lack of activity. If there's still interest let's discuss in #28.

@annevk annevk closed this Oct 11, 2022
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.

None yet

3 participants