Skip to content

Cycle "Every Day" at midnight, not every 24 hrs #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Ikigai.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ export class Ikigai extends Component {
let time_now = Math.round(new Date().getTime() / 1000);
let background_update_freq = parseInt(this.state.background_cycle);

if (background_update_freq == 86400) {
background_last_updated = new Date(background_last_updated * 1000).setHours(0,0,0,0)/1000;
}

if (background_last_updated + background_update_freq <= time_now) {
this.refetchAndSetImageHidden();
let time_now = Math.round(new Date().getTime() / 1000);
Expand Down Expand Up @@ -241,6 +245,10 @@ export class Ikigai extends Component {
localStorage.getItem("background_last_updated")
);

if (background_update_freq == 86400) {
background_last_updated = new Date(background_last_updated * 1000).setHours(0,0,0,0)/1000;
}

console.log(
`Next Background change at ${this.unixToHumanTime(
background_update_freq + background_last_updated
Expand Down