vladimiry / ElectronMail

Unofficial ProtonMail Desktop App
GNU General Public License v3.0
1.48k stars 96 forks source link

Unpredictable badge activity? #656

Open k3n51mm opened 7 months ago

k3n51mm commented 7 months ago

Using the latest ElectronMail 5.22. Observed on both Kubuntu and Windows 10.

The unread mail badge that appears over the green ElectronMail icon in the system tray when minimized is now red instead of blue. That's not really a problem, except that as far as I can understand so far, it's now behaving erratically.

I've tested several times today. This morning at around 10 Pacific time it worked as expected. I saw the icon appear, opened ElectronMail, opened the message and the icon went away as expected.

Then I tried it again at noon and 2pm, and the red icon never appeared, but the test email was waiting once I manually opened the ElectronMail program and checked.

I finally posted this issue when just now I saw the red icon, opened the unread message, and the red icon would not go off until I unloaded the account in question and then reloaded it.

Either I don't know how to configure my settings, or something may be wrong.

Thanks for a fantastic program, hope I get it working right again.

k3n51mm

vladimiry commented 7 months ago

The guess is that Proton has changed some API related to receiving summary "unread" information. Will have to look into it in a debugger to say something specific.

It appears to keep working well if the local store option is enabled for the mail account - the app doesn't scan the summary "unread" API calls in this case, but derives the unread counters from the own local database.

vladimiry commented 7 months ago

I just did a brief testing on one account and one mail by switching its "unread" status on/off, and could not reproduce the issue so far. So I'm not jumping into the debugging yet, but will do if more issue reports come here.

k3n51mm commented 7 months ago

Just to follow up. I still haven't figured out why the badge wasn't working normally just after installing, but it has "settled down" since posting this issue. Being a developer myself, I'm still suspicious of whatever happened, but there appears to be nothing wrong with Electron Mail - as long as Proton Mail is working correctly. Thanks for looking into it.

k3n51mm commented 7 months ago

Well the problem has recurred. Upon restarting the machine where Electronmail is installed after a Windows update, it started fine, no problems with logging into the several accounts at Proton Mail. However, I later received several emails and the red badge didn't appear; I only discovered them by opening the Electronmail screen. Then I sent a test email and again no badge.. So I restarted Electronmail, all accounts logged in successfully, but still no badge. Just tried it again with the same result.

vladimiry commented 7 months ago

Some screenshots would help I guess, to reduce possibility for misunderstanding.

k3n51mm commented 7 months ago

Please note the icon in the system tray with no new email badge, and the unread email displayed once the Electronmail screen is opened. In addition, when operating as you intended, there is usually another rounded square icon which shows the number of unread messages, shown at the left of the tab of the email account which has the unread message. I rely on this great program, so I'm glad to help with testing if needed. THX electronmail

vladimiry commented 7 months ago

The issue like this could potentially happen if Proton has changed /v4/messages/count API format or the address, as the app scans the response of this API. So going to look into it in a debugger.

k3n51mm commented 7 months ago

Much appreciated, pls let me know if you have a monetization channel, this is a fantastic program and I'm happy to pay or donate. Thx, KS

vladimiry commented 7 months ago

I did some debugging and the above-mentioned API scans appear valid. I can't reproduce the issue yet at my side.

I'm surprised no one except you reported the issue so far, which makes me think Proton might have some account-related setting which makes unread counters related logic work differently in terms of API use. @k3n51mm was it worked for you as expected before v5.2.2?

Btw, I normally use the local store feature enabled for the account and in this case unread notification value calculation works differently (deriving unread values from the local database vs scanning the response of /core/v4/events / /mail/v4/messages/count API calls), you could try it too.

Also, currently if the local store is not enabled for the account, the app shows unread notification for the Inbox folder only. I'm changing it to "all folders" by 8378e3b967f3bc7a9e67f4cc8a19e497e87920a4, so it works similar in both modes.

if you have a monetization channel

No such channel at the moment, but you could subscribe to #258 if you wish.

k3n51mm commented 7 months ago

I have changed all accounts to 'local store', and the notifications seem to be working again. Maybe there's something changed in the web API calls as you surmised. Thanks! KS

Dementor316 commented 7 months ago

Hello, dear @vladimiry! Since my issue is related to this issue, I thought it would be pointless to create a new one if I could report everything in the existing issue. I stopped receiving notifications about unread messages on the icon and in the Windows 10 system notifications immediately after updating to version 5.2.2. Everything worked fine without any problems on version 5.2.1 - I always received notifications about new messages in my two accounts. Local Store function is always enabled, and I have reinstalled the program several times, but notifications about unread messages no longer appear when ElectronMail is minimized to the tray. It so happened that recently I also reinstalled Windows hoping that it would somehow help fix the problem with ElectronMail notifications, but unfortunately, in version 5.2.2, notification functionality has completely disappeared for me. I would gladly go back to version 5.2.1 if it worked, but there Proton does not allow interaction with an outdated ProtonMail web package mailbox. I don't know how to solve my problem and restore notifications about unread messages anymore. I have reviewed all Windows 10 features related to notifications, but nothing seems to prevent ElectronMail from displaying notifications anywhere or anytime they are turned on within ElectronMail itself as well. I am puzzled by how to solve this problem. I have Windows 10 PRO 22H2 64 Bit

vladimiry commented 7 months ago

@Dementor316, so far I couldn't reproduce the issue at my side, and there were no related changes in the project code between versions 5.2.1 and 5.2.2. So it's either Proton changed things which I briefly debugged and didn't detect the issue there, or some dependencies, including @electron itself, got updated with this side effect.

Is there a correct unread counter in the app itself, inside the account handle button? If so, then the app still correctly detects/derives the unread counter, but the notification itself doesn't get displayed for some reason. You can try making alternative/external notification by putting similar code to the "Shell command execution" edit area located under the "Desktop Notifications" block on the account edit form (I didn't test the powershell "[console]::beep(500,300)" code as currently there is no Windows system at my side, but it's supposed to make beep sound):

formatNotificationShellExecArguments(() => {
  return {command: `powershell "[console]::beep(500,300)"`};
});

Also, if you have enabled "Shell command execution" or/and "Custom notification content" toggles located under that collapsible "Desktop Notifications" block, try disabling them both and see if it helps.

Dementor316 commented 7 months ago

@vladimiry, all unread message counters inside the ElectronMail program are still displayed correctly, the problem only arises with displaying the number of unread messages on the tray icon and system notifications. Thank you for your suggestion, I will try to use this external notification through PowerShell sound so that I can at least quickly and unproblematically find out about new messages. I have never configured custom notification settings in ElectronMail and they are disabled by default. I hope that sooner or later Electron or you will be able to fix this unpleasant error. Thank you!

vladimiry commented 7 months ago

the problem only arises with displaying the number of unread messages on the tray icon and system notifications.

Thanks for confirming a guess, so the issue scope got narrowed down now.