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

FIX: Update do-not-disturb icon in real-time on glimmer header #27021

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

davidtaylorhq
Copy link
Member

To achieve this, a new ReactiveTargetDate 'resource' is introduced. This is constructed using a callback, which should return the target date (in this case, when do-not-disturb will end). The utility then provides an autotrackable .hasPassed getter which returns a boolean.

This resource needs to be properly torn down at the end of the application lifecycle in tests, so the logic is moved out of the user model and into a new Notifications service.

@janzenisaac
Copy link
Contributor

@davidtaylorhq how do you feel about @dedupeTracked being used in the wild? It seems like a very useful function that I could envision using in a lot of custom cases.

@davidtaylorhq
Copy link
Member Author

Yeah for sure - I hope it will be useful elsewhere!

@davidtaylorhq davidtaylorhq marked this pull request as draft May 20, 2024 10:42
To achieve this, a new ReactiveTargetDate 'resource' is introduced. This is constructed using a callback, which should return the target date (in this case, when do-not-disturb will end). The utility then provides an autotrackable `.hasPassed` getter which returns a boolean.

This resource needs to be properly torn down at the end of the application lifecycle in tests, so the logic is moved out of the user model and into a new Notifications service.
}

willDestroy() {
this.#dndReactiveTargetDate?.destroy();
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't it be better to use the getOwner/setOwner pattern so that it gets destroyed automatically?

you can forget calling the destructor but you can't forget passing in a "required"/first argument 😛

Copy link
Member Author

Choose a reason for hiding this comment

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

That was my first try. But unfortunately getOwner/setOwner is separate from Ember's "destroyable" system. Destroying the application does not automatically destroy things which are owned by it. 😬

But yeah, I do agree this manual stuff is not ideal. Will see if I can figure something out 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants