[applets/digital-clock] Fix calendar events not being shown at first
ClosedPublic

Authored by epopov on Mar 27 2020, 4:46 PM.

Details

Summary

I noticed that on the first time I bring up the calendar by clicking the clock on my Plasma panel, it always shows "No event for today". If I click another day on the calendar and then click back on today, it shows today's events fine. It should display it correctly the first time.

To fix this bug, we need to compare the date without time.

BUG: 395956
FIXED-IN: 5.19.0

Diff Detail

Repository
R120 Plasma Workspace
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
epopov created this revision.Mar 27 2020, 4:46 PM
Restricted Application added a project: Plasma. · View Herald TranscriptMar 27 2020, 4:46 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
epopov requested review of this revision.Mar 27 2020, 4:46 PM

No need to put the function in a separate file; you should put it in CalendarView.qml. Since it's only used once, it could even be inline without defining a new function at all. That's a judgment call though.

ngraham retitled this revision from Bug 395956: calendar events are not shown at first to [applets/digital-clock] Fix calendar events not being shown at first.Mar 27 2020, 4:52 PM
ngraham edited the summary of this revision. (Show Details)
epopov updated this revision to Diff 78694.Mar 27 2020, 6:39 PM

Make a function that compares dates inline.

If you're gonna have the function live inside the onAgendaUpdated: handler and only be used once, it might as well not be a function at all. :) If you want to keep it a function, it would be good to put it higher up in the file, so it can potentially be used by other things in the future.

epopov updated this revision to Diff 78715.Mar 28 2020, 8:42 AM

Put the dateEquals function outside the onAgendaUpdated handler, so it can be used elsewhere.

ngraham accepted this revision.Mar 28 2020, 7:56 PM

Thanks!

This revision is now accepted and ready to land.Mar 28 2020, 7:56 PM

Can you rebase this patch on current master?

epopov updated this revision to Diff 78853.Mar 30 2020, 8:23 AM

Rebase to master

ngraham edited the summary of this revision. (Show Details)Mar 30 2020, 2:09 PM
This revision was automatically updated to reflect the committed changes.
broulik added inline comments.
applets/digital-clock/package/contents/ui/CalendarView.qml
154

Can't you do date1.getTime() == date2.getTime() (time returns the msecs since epoch)

epopov added inline comments.Mar 30 2020, 4:16 PM
applets/digital-clock/package/contents/ui/CalendarView.qml
154

How can I compare only the date using your expression?