Zren / plasma-applet-eventcalendar

https://store.kde.org/p/998901/
470 stars 93 forks source link

Hide network error following an `allDataFetched` event #293

Open mvastola opened 2 years ago

mvastola commented 2 years ago

See #292.

Fixes Zren/plasma-applet-eventcalendar#292 Fixes Zren/plasma-applet-eventcalendar#273

Zren commented 2 years ago

The allDataFetched signal is probably a bad name. It's really "all async fetches have completed". fetchGoogleAccountEvents_err() will also asyncRequestsDone += 1 which emits allDataFetched() if asyncRequestsDone >= asyncRequests) {.

I'm guessing if you disconnect your network/wifi, the error will still get hidden.

Not sure if I sure remove asyncRequestsDone += 1 from the _err function. I'll need to skim the listeners of AllDataFetched and AsyncRequestsDoneChanged to see if there will be any bugs.

mvastola commented 2 years ago

The allDataFetched signal is probably a bad name. It's really "all async fetches have completed". ` I'm guessing if you disconnect your network/wifi, the error will still get hidden.

I actually thought of this and tried it, and it shows and doesn't get hidden if I'm disconnected.

My best guess as to why is that the showError function also gets called for each allDataFetched signal iif the network is down.

I do wonder if that might be due to (or succeptable to) a race condition, but I'm not too familiar with the order of operations and dependencies here. I imagine there's a way to do this that's thread-safe, however.

Not sure if I sure remove asyncRequestsDone += 1 from the _err function. I'll need to skim the listeners of AllDataFetched and AsyncRequestsDoneChanged to see if there will be any bugs.

Please do.

My other idea is (if this implementation doesn't work out) is we can add (in addition to asyncRequestsDone) a new property called asyncRequestsFailed, and if it's zero after the signal, clear the error. (Obviously you'll want to reset it to zero after each fetch all.)

Only reason I didn't go that route is this seemed more straightforward and I don't know the QML syntax well enough to be sure I'm doing it right.