Updating AppBadge seems to break with twitter on macOS because inject code is returning NaN
plugandplay opened this issue · comments
Hello,
When I try to set up my Twitter account, ttth displays this error in a loop as soon as I am logged in.
TypeError: Error processing argument at index 0, conversion failure from null
at App.setBadgeCount (electron/js2c/browser_init.js:6976:31)
at IpcMain.<anonymous> (/Applications/ttth.app/Contents/Resources/app.asar/main.js:641:47)
at IpcMain.emit (events.js:203:13)
at IpcMain.EventEmitter.emit (domain.js:476:20)
at WebContents.<anonymous> (electron/js2c/browser_init.js:3849:15)
at WebContents.emit (events.js:203:13)
at WebContents.EventEmitter.emit (domain.js:476:20)
at WebContents.emitter.emit (/Applications/ttth.app/Contents/Resources/app.asar/node_modules/@sentry/electron/dist/main/integrations/electron.js:55:20)
at WebContents.topLevelDomainCallback (domain.js:131:23)
ttth 1.8.20200228
Electron 7.1.11
darwin 18.7.0
Locale: fr
Thank you very much for your first issue to this project. It is much appreciated.
@plugandplay
thanks for the issue/report.
to be honest - i am not using twitter myself in ttth.
I'll take a look into it tomorrow and see if i can reproduce your issue.
Am i guessing right that the error is displayed after finishing the service configuration?
After finishing the service configuration, I was able to see the Twitter login page.
The bug occurred right after I filled the login form.
@plugandplay
i just set up a twitter service on my developing machine (linux).
On the first look it works as expected.
I can login without issues or error messages.
What i do notice here is that the inject code which is used to detect unread messages seems to fail.
This means there is a green Badge showing "NaN" in the service tab.
But this is not related with your problem - more a general problem with the inject code.
But in general it just works.
Some questions
- Regarding service url: did you change the service url in the service configuration window? By default it is set to https://mobile.twitter.com
- Regarding os: your issue is tagged as darwin 18.7. Is that a current macOS?
What might be helpful is:
- start ttth and remove the service
- close ttth
- start ttth and press F12 (or by Menu -> Help -> Console -> Console) to open the dev console. (shows logging)
- switch to the settings tab and re-add the twitter service
- paste the content of the dev console here.
non-problem related - but as i am curious:
are you using any other services? If so - do they work as expected and how is your experience in general with ttth?
Well, the error is displayed in loop as soon as I restarted ttth. It has been difficult to remove the Twitter service.
To answer your questions:
- I didn't change the service URL, or anything else.
- My OS is macOS Mojave (Version 10.14.6).
- Before I tried the Twitter service, I have set up WhatsApp without any problem.
After removing the Twitter service, I still don't have a problem with WhatsApp.
I started using ttth yesterday so I am not an experienced user yet. I really like the idea of a FOSS app to replace those of many vendors.
Here are the console logs with errors after I add the Twitter service again:
/Applications/ttth.app/Contents/Resources/app.asar/node_modules/@sentry/utils/dist/instrument.js:104 08:43:25.531 › [ Renderer ] updateServiceBadge ::: New unread count for service _twitter_j9Dfgb5D5AdIK5CMnzhSFhw7_ is: _NaN_.
/Applications/ttth.app/Contents/Resources/app.asar/node_modules/@sentry/utils/dist/instrument.js:104 08:43:25.533 › [ Renderer ] updateTrayIconStatus ::: Unread messages count of _twitter_j9Dfgb5D5AdIK5CMnzhSFhw7_ is: NaN
/Applications/ttth.app/Contents/Resources/app.asar/node_modules/@sentry/utils/dist/instrument.js:104 08:43:25.534 › [ Renderer ] updateTrayIconStatus ::: Overall unread message count for all enabled services is: _NaN_.
@plugandplay
i am not yet sure why this happens - as i havent it tested yet on MacOS
What you might test is
DISABLE THE TWITTER INJECT CODE
- open ttth
- switch to the settings tab
- press the folder button below the listed configured services. This open a directory where a .json file is located for each of your defined services
- Now close ttth
- Create a backup of
twitter_SOMERANDOMSTRIN.json
somewhere outside of this folder (i.e. your desktop) - Open the original
twitter_SOMERANDOMSTRIN.json
in your favorite text editor - Remote the path to the injectcode
The following is just an example
from:
{"type":"twitter","name":"Twitter","icon":"fab fa-twitter","url":"https://mobile.twitter.com/","injectCode":"./js/ttth/services/twitter/twitter_inject.js","serviceEnableStatus":true,"userAgentDefault":"","userAgentCustom":""}
to
{"type":"twitter","name":"Twitter","icon":"fab fa-twitter","url":"https://mobile.twitter.com/","injectCode":"","serviceEnableStatus":true,"userAgentDefault":"","userAgentCustom":""}
- save the file
- start ttth
Please report back if that changes something.
To explain what this is doing:
- each service a user has configured has its own .json config file
- based on the service and its states the content differs
- the inject_code (if existent) for a service_type is injected in the service session and tries to collect informations about unread messages (in case of twitter: unread DMs) etc - to update the service badge
tldr
my idea is to disable this inject code for testing purposes to see if that changes the behaviour.
@plugandplay
i guess i understood where the problem is coming from.
Some time ago i've added code which:
- tries to detect if the operating system of the user is supporting AppBadges (a badge next to the application icon). This is valid for
- macOS
- linux if unity environment is used
- if it is supported - ttth tries to use it
You as mac user have an environment where my code is realizing that AppBadges are technically supported - and therefor tries to use it.
The function which i am using there seems to be deprecated but still functional. The real problem is that the inject_code i am using fro twitter no longer reports a valid number, but just NaN (NotANumber)
I'll let you know when it is fixed - in the meantime you can twitter in ttth using the hackery mentioned in the post above:
DISABLE THE TWITTER INJECT CODE