Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

ipcMain.on('unreadCount') is never called in foreign languages #131

Open
alescdb opened this issue Nov 23, 2022 · 5 comments
Open

ipcMain.on('unreadCount') is never called in foreign languages #131

alescdb opened this issue Nov 23, 2022 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@alescdb
Copy link

alescdb commented Nov 23, 2022

As stated in my PR, if Google Chat is not in english (at least in French), ipcMain.on('unreadCount') is never called :

image

Because in french data-tooltip is not "Chat" or "Space" but "Discussions" and "Espaces".

@ankurk91
Copy link
Owner

How to ensure a consistent dom xpath to that element?

@ankurk91 ankurk91 added the help wanted Extra attention is needed label Nov 24, 2022
@alescdb
Copy link
Author

alescdb commented Nov 24, 2022

How to ensure a consistent dom xpath to that element?

It looks like document.querySelectorAll('.XS > span > .XU') is working (at least for me).
We can try to use it and fallback to data-tooltip if it fails with something like :

const getMessageCount = (): number => {
  let counter = 0;

  let elems = document.querySelectorAll('.XS > span > .XU');
  if (elems && elems.length > 0) {
    elems.forEach((item) => {
      counter += Number(item.textContent);
    });
    return (counter);
  }

  document.body.querySelectorAll(targetSelectors.join(',')).forEach((target) => {
    const span = target.querySelector('span[role="heading"]')?.nextElementSibling
    if (span) {
      counter = counter + Number(span.textContent)
    }
  })
  return counter
}

I can submit a PR if you want.

@ankurk91
Copy link
Owner

It is not the best solution, it will break whenever google will deploy new version of their css

@alescdb
Copy link
Author

alescdb commented Nov 24, 2022

Another not optimal solution would be to force the UI language to English and allow user to select a different spell check language.

@ankurk91
Copy link
Owner

Sorry, i dont have time to build and test such feature on all platforms.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants