Conversation
|
Hi, sorry for the delay on looking at PRs. I'm a bit concerned that you're attaching a mutation observer to document.body here with those flags. Given how frequently the DOM changes on Twitch, that's a lot of processing overhead for something that is going to appear very infrequently. I effectively never get a notification with a redemption code in it so I can't really test this myself, but can this be refactored to have less processing? |
|
Okay, I'll work on it, I unfortunately don't know what methods to use as the documentation for this code is basically non-existent, but maybe I didn't look correctly for a documentation website. But, yea, thank you for the input, I'll see to the changes being fixed. What could help, is if you know of a way I can bind the execution of the DOM manipulation to the notifications dialog opening. I cannot seem to figure out what I would do for that. |
|
Alright, so, I looked into notifications a little for you. I believe your code is looking for the window that opens when someone clicks the notification, and not for toasts, right? There's a React class-based component that handles that, so you can use the // top of file
const MY_RAF = Symbol('my-unique-raf');
// in constructor()
this.inject('site.fine');
this.NotificationManager = this.fine.define(
'notification-manager',
n => n.readNotification && n.toggleCenter && n.deleteNotification
);
// in onEnable()
this.NotificationManager.on('mount', this.checkNotifications, this);
this.NotificationManager.on('update', this.checkNotifications, this);
// later
checkNotifications(inst) {
const node = this.fine.getChildNode(inst);
if (node && !node[MY_RAF])
node[MY_RAF] = requestAnimationFrame(() => {
node[MY_RAF] = null;
// do something with node here
});
}That triggers whenever the user opens or closes the notification window, or even changes the page. In that example, |
|
Here is a little update, gotta wait for a new code redeem to be available for something I play/participate in, to make sure it works. But will be pushing what I have soon. |
I hate having to go into the inspect element to copy the code for a redeem in a notification, so I, made this.
If you need me to change anything, let me know I'll be happy to!