Skip to content

Conversation

@psieg
Copy link
Contributor

@psieg psieg commented Jan 19, 2023

This keeps relative dates accurate when the calendar's fetch frequency is much larger than a minute.
As fetching incurs network traffic and load on servers and most calendars don't update that often, simply refreshing locally is enough.

When using relative for today's events, dates will show as "in X minutes" or "ends in X minutes" for events within an hour and this goes out of date quickly. It's weird to see that the time is, say, 16:30 and an event that you know ends at 16:45 is shown to "ends in 23 minutes" because that's when the last fetch happened.

Please forgive me if there's style issue, I don't have npm set up on my machine to run the formatter.

This keeps relative dates accurate when the calendar's fetch frequency is much larger than a minute.
As fetching incurs network traffic and load on servers and most calendars don't update that often, simply refreshing locally is enough.
// Override start method.
start: function () {
const ONE_SECOND = 1000; // 1,000 milliseconds
const ONE_MINUTE = ONE_SECOND * 60;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const ONE_MINUTE = 60000;

is clear enough :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was in line with the rest of the file, I don't mind.

@rejas
Copy link
Collaborator

rejas commented Jan 19, 2023

Good idea and PR. Just some minor clean/clear ups :-)

@codecov-commenter
Copy link

Codecov Report

Merging #3016 (931996f) into develop (4244c05) will increase coverage by 0.05%.
The diff coverage is 0.00%.

@@             Coverage Diff             @@
##           develop    #3016      +/-   ##
===========================================
+ Coverage    21.76%   21.82%   +0.05%     
===========================================
  Files           52       52              
  Lines        11441    11451      +10     
===========================================
+ Hits          2490     2499       +9     
- Misses        8951     8952       +1     
Impacted Files Coverage Δ
modules/default/calendar/calendar.js 35.17% <0.00%> (-0.40%) ⬇️
modules/default/updatenotification/node_helper.js 90.27% <0.00%> (+12.50%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@rejas rejas merged commit f6dcfb5 into MagicMirrorOrg:develop Jan 26, 2023
@psieg psieg deleted the calendar-refresh branch January 26, 2023 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants