KartikTalwar / gmail.js

Gmail JavaScript API
MIT License
3.74k stars 455 forks source link

gmail.observe.on('view_thread') not working #731

Closed zayaserg closed 1 year ago

josteink commented 1 year ago

More info would be appreciated 🙂

cancan101 commented 1 year ago

As of somewhat recently, a subscription to the view_thread event no longer seems to fire even though a thread is viewed. I will have to investigate further.

The view_email listener does still fire.

I am not seeing any .if elements in the DOM: https://github.com/KartikTalwar/gmail.js/blob/8b73a6b582df119d1060cd5699d1711ae0760387/src/gmail.js#L2467

cancan101 commented 1 year ago

I changed the sub_selector to: 'div.PeIF1d' and it works

josteink commented 1 year ago

PRs welcome.

cancan101 commented 1 year ago

Happy to put up a PR, but I do have one open question. It looks like the sub_selector concept only supports a single value; however, for backward comparability I think we'd want to keep the old selector as well as adding the new selector. Thoughts?

josteink commented 1 year ago

Agreed.

If this is going to be a recurring problem, adding general support for multiple sub-selectors is probably not a bad and nothing I fundamentally have an issue with.

Try it out and see if you can make it work?

MadcowD commented 1 year ago

This looks good!

MadcowD commented 1 year ago

@josteink is there anyway you could merge this? I'd love to update our app.

josteink commented 1 year ago

I was too quick in the review/testing of previous PR.

Upon proper testing I can't make this work at all. Not on new PR-code nor on old master code.

I guess that means there's more work to be done here, but I can't fix that now. I don't have time, at least until sometime next week.

cancan101 commented 1 year ago

@josteink I am a bit confused here. Are you saying this change broke your experience?

josteink commented 1 year ago

No I'm saying it didn't work without this fix, but it doesn't work with it either.

view_email event works though (no change).

josteink commented 1 year ago

The fix in its current state is released in new version 1.1.5. No guarantees it will work, but at least it should make it easier to test.

cancan101 commented 1 year ago

Okay, I just did a hard refresh of my gmail and it seems like the class name used by gmail has changed once again. So agreed, this fix does not work.

josteink commented 1 year ago

I guess that means we might have to use a higher level selector (.bu?) and try to filter it more intelligently in code further down (look for data-thread-id properties)?

Basically something which is generic enough to survive such changes, but not wide enough to cause performance issues.

cancan101 commented 1 year ago

Ok, I think a better sub_selector is iY which given its length and proximity to if is more likely to be stable (?).

josteink commented 1 year ago

PRs welcome 🙂

cancan101 commented 1 year ago

https://github.com/KartikTalwar/gmail.js/pull/735

josteink commented 1 year ago

Merged, available in 1.1.6.