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

Make notifications permanently dismissed #283

Merged
merged 13 commits into from
Jun 20, 2024
Merged

Conversation

zanderle
Copy link
Collaborator

@zanderle zanderle commented Apr 5, 2024

POC for now

Closes #46

Copy link
Member

@humitos humitos 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 this is going in the direction we need. However, there are some changes in the logic we should make here.

From @agjohnson's comment in #46 (comment)

Implement cookie/local storage tracking of per-build notification dismissal. Subsequent page loads don't show the notification at all.

I understand we shouldn't dismiss this notification for all the PRs just by closing the notification, but only on this particular build. So, we should save the build.pk in the storage so we know on which build we shouldn't show.

That is, closing the notification on the first page, won't show it on any of the following page from the same build. Then, if the PR is rebuilt, it will show the notification again.

Besides, if the user opens a different PR preview the notification will be shown again.


Also, note that this addons shows a notification for PR builder and for stable/latest versions so the storage will affect those as well. We may want to split this notification addon (see #201) before moving forward with this or consider this scenario here.

src/notification.js Outdated Show resolved Hide resolved
src/notification.js Outdated Show resolved Hide resolved
@humitos humitos marked this pull request as draft April 16, 2024 08:34
@zanderle zanderle requested a review from humitos April 25, 2024 17:14
Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

This approach looks good to me! 👍🏼

Is it ready to merge? I'm asking because it's in Draft and I'm not sure if you are still working on it or not, @zanderle

@zanderle
Copy link
Collaborator Author

This approach looks good to me! 👍🏼

Is it ready to merge? I'm asking because it's in Draft and I'm not sure if you are still working on it or not, @zanderle

No, I just need to use these new functions in the search addon as well.

Also are we ok with the behaviour implemented here (in terms of permanently dismissing the notification), or does that require further testing/discussion?

@humitos
Copy link
Member

humitos commented May 22, 2024

I think this approach is fine. I understand the local storage is based on the domain, right? In that case, dismissing a notification on a pull request won't affect latest/stable notifications, which is great.

However, dismissing a latest notification on https://docs.readthedocs.io/en/latest/ will also dismiss the stable notification on the same domain, for example when hitting https://docs.readthedocs.io/en/0.9.x/. So, I suppose the local storage key should be based on the version as well: with a postfix of this.config.versions.current.slug probably to make it explicit.

Am I correct?

@humitos
Copy link
Member

humitos commented May 27, 2024

We also serve multiple projects under the same domain, when they are subprojects. So, I think we should save the project-slug and version-slug in the local storage key as well.

@agjohnson
Copy link
Contributor

agjohnson commented May 28, 2024

Tracking this per subproject could be too granular, and tracking per version feels really granular. There is a good chance that if a user dismisses this once they will want it dismissed everywhere. If a user has to dismiss notifications for each version, it will feel like dismissal isn't working correctly.

For me, this keeps coming back to prompting the user for what they want -- dismiss for now, for this project, for all projects of parent project, etc.

For that, tracking the subproject is okay, as long as our plan for storage/data allow these patterns later.

@humitos
Copy link
Member

humitos commented May 29, 2024

Tracking this per subproject could be too granular, and tracking per version feels really granular. There is a good chance that if a user dismisses this once they will want it dismissed everywhere.

If the user see a notification "this is an old version" for a project and dismiss it, and then open an old version of a subproject, I think we should show the notification again. They are different projects and different versions, so the user should be warned about reading an outdated version of the subproject to avoid confusions.

That's the v1 of the implementation. In a next iteration we can work on the granularity and configuration/prompting, but we are not there yet.

@agjohnson
Copy link
Contributor

That is fine for the latest/stable build warning, but the PR build warning is still fairly different.

As a user, I understand what I'm seeing is a PR build after clicking through from the PR once or twice. Reminding me every time, and requiring me to close the notification every PR, is what feels redundant. This notification is in a different class as it's not for reader users but for the maintainer, who interacts with the notification frequently.

@humitos
Copy link
Member

humitos commented May 30, 2024

Yes, PR notification and stable/latest should behave differently. In fact, I want to split this addon into different ones because we've reach this differences in behavior multiple times already and having only 1 addon for all of them makes everything harder and more confusing.

@humitos
Copy link
Member

humitos commented May 30, 2024

@zanderle can you implement the initial version of the dismiss that consider domain, project, version and language slug?

Behavior:

  • dismissing the notification won't show it again on the same project, version, language
  • switching any of them will make the notification to show again
  • dismissing the notification on PR builds, won't show it again on that PR preview

In the next iteration we will split the notification addon and consider the user configuration (e.g. dismiss all PR notifications always for all the domains, etc)

@zanderle
Copy link
Collaborator Author

@humitos I think I can. Let me dig in, and I'll let you know in case I run into any complications.

@zanderle zanderle force-pushed the zanderle/close-notifications branch from 3a649cf to acdfec8 Compare June 17, 2024 15:11
@zanderle
Copy link
Collaborator Author

zanderle commented Jun 17, 2024

@zanderle can you implement the initial version of the dismiss that consider domain, project, version and language slug?

Behavior:

  • dismissing the notification won't show it again on the same project, version, language

@humitos Ok, so project is covered by the domain name, and I can add this.config.versions.current.slug to the localstorage key to cover the version. How should I determine the language? projects.current.language.code or something else?

Is it ok to rely on the domain name to consider project, or should that be a separate thing as well? projects.current.slug perhaps?

@agjohnson
Copy link
Contributor

agjohnson commented Jun 17, 2024

If we want to give users notifications for each subproject, we will need to use the project slug.

I'd like to see this merged soon so we can fix this UX bug with notifications. I feel we're maybe getting deep into optimizing this up front for use cases. We instead could start with something simple, what's here now, and make dismissals more granular as we continue working on this.

This PR has felt like it was really close, what is left to be able to merge a fix for dismissing PR build notifications? Reworking methods the search addon uses, maybe tests?

@zanderle
Copy link
Collaborator Author

If we want to give users notifications for each subproject, we will need to use the project slug.

I'd like to see this merged soon so we can fix this UX bug with notifications. I feel we're maybe getting deep into optimizing this up front for use cases. We instead could start with something simple, what's here now, and make dismissals more granular as we continue working on this.

This PR has felt like it was really close, what is left to be able to merge a fix for dismissing PR build notifications? Reworking methods the search addon uses, maybe tests?

@agjohnson yeah, at this point what's left is changing the local storage key and some tests (although I'll have to check if cookies complicate things at all). I was going to also rework the search addon to use the same util functions, but that could also be a separate PR, if you wanted to expedite this one?

@humitos
Copy link
Member

humitos commented Jun 18, 2024

@zanderle yes, we should use those three variables for the local storage key:

  • Project slug: this.projects.current.slug
  • Project language code: this.projects.current.language.code
  • Version slug: this.config.versions.current.slug

@zanderle zanderle force-pushed the zanderle/close-notifications branch from 4fe12db to 458b35b Compare June 18, 2024 14:29
@zanderle zanderle force-pushed the zanderle/close-notifications branch from 458b35b to fae02e2 Compare June 18, 2024 14:33
@zanderle zanderle force-pushed the zanderle/close-notifications branch from fae02e2 to cb9a62e Compare June 18, 2024 14:39
@zanderle
Copy link
Collaborator Author

@humitos this should be ready for review, except for tests. I'm trying to figure out what would be the best way to test the behaviour

Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

It looks good to me 👍🏼 . I left some comments with suggestions. Let me know.

src/notification.js Show resolved Hide resolved
src/notification.js Outdated Show resolved Hide resolved
src/notification.js Outdated Show resolved Hide resolved
@zanderle zanderle force-pushed the zanderle/close-notifications branch from edb1a9a to 52ea194 Compare June 19, 2024 19:04
@zanderle zanderle marked this pull request as ready for review June 19, 2024 20:40
};
const localStorageString = JSON.stringify(addonInformation);
getLocalStorageStub
.withArgs("readthedocs-Notification-storage-key")
Copy link
Member

@humitos humitos Jun 20, 2024

Choose a reason for hiding this comment

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

Does it make sense to use addon.getLocalStorageKeyFromConfig(config) here (and other places) instead of hardcoding it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think it's better to hardcode it, because this way we also test that we don't get some accidental readthedocs-undefined-storage-key or something like that.

@zanderle zanderle requested a review from humitos June 20, 2024 12:54
Copy link
Member

@humitos humitos left a comment

Choose a reason for hiding this comment

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

I did some small tests locally and it works fine to me 💯 . Thanks @zanderle for working on this feature with all the back and forth we had 😄 . I really appreciate it 🙏🏼

@humitos humitos merged commit 36cf19c into main Jun 20, 2024
4 checks passed
@humitos humitos deleted the zanderle/close-notifications branch June 20, 2024 15:56
@zanderle
Copy link
Collaborator Author

zanderle commented Jun 20, 2024 via email

humitos added a commit that referenced this pull request Aug 5, 2024
…#353)

Fixes #296 

A few considerations here:
- I used the new localStorage code that we added in #283 . This means
the key for localStorage will change once this is deployed, meaning that
previous recent searches won't show up anymore (and there will be an
unused object in localStorage lying around). Are we ok with that, or do
we want to make it backward compatible?
- I didn't add any logic for removing recent searches from previous
versions. If we don't add anything, this object will grow and grow and
it will store recent searches of versions that might become very old. Do
we want to add some kind of logic in this PR or should we do it in a
separate PR?
- Besides project and version, I also added language to the key (the
same way we do it for notifications). Is that ok?

---------

Co-authored-by: Manuel Kaufmann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Notification: use a cookie to keep it closed for the session
3 participants