From 68701f6436f38a229332fc754fabcd26e9779bc9 Mon Sep 17 00:00:00 2001 From: YassinEldeeb Date: Sat, 2 Apr 2022 02:00:29 +0200 Subject: [PATCH] fix: schedule run at minutes left till the next hour --- .../{twitter-card.png => web-screenshot.png} | Bin schedular/src/lib.rs | 22 ++++--- website/components/Nav.tsx | 59 +++++++++++------- website/components/Section.tsx | 2 +- website/pages/Hero.tsx | 2 +- website/tailwind.config.js | 3 + 6 files changed, 58 insertions(+), 30 deletions(-) rename .github/images/{twitter-card.png => web-screenshot.png} (100%) diff --git a/.github/images/twitter-card.png b/.github/images/web-screenshot.png similarity index 100% rename from .github/images/twitter-card.png rename to .github/images/web-screenshot.png diff --git a/schedular/src/lib.rs b/schedular/src/lib.rs index 1f7a113..a7f0d1b 100644 --- a/schedular/src/lib.rs +++ b/schedular/src/lib.rs @@ -7,7 +7,6 @@ mod system_tray; use std::{ env, fs, sync::{Arc, Mutex}, - time::Instant, }; use chrono::{Local, NaiveDateTime}; @@ -51,26 +50,36 @@ pub fn start_schedular(exit: Arc>) { let mut sched = JobScheduler::new(); if conf.show_hours { - // Run every minute 0 (aka: every begining of a local hour) + let minutes_till_next_hour = get_minutes_left(&conf) % 60 + 1; + let minutes_till_next_hour = if minutes_till_next_hour == 60 { + minutes_till_next_hour - 1 + } else { + minutes_till_next_hour + }; + + // Run every minute 0, second 0 (aka: every begining of a local hour) sched - .add(instantiate_job("* 0 * * * * *", conf.clone())) + .add(instantiate_job( + &format!("0 {} * * * * *", minutes_till_next_hour), + conf.clone(), + )) .unwrap(); } else if conf.show_days { // Run every midnight sched - .add(instantiate_job("* 0 0 * * * * *", conf.clone())) + .add(instantiate_job("0 0 0 * * * * *", conf.clone())) .unwrap(); } else if conf.show_weeks { // Run every week // First day in the week = Sunday. // TODO: ask for the weekend of a user. sched - .add(instantiate_job("* 0 0 * * 7 *", conf.clone())) + .add(instantiate_job("0 0 0 * * 7 *", conf.clone())) .unwrap(); } else if conf.show_months { // Run every month sched - .add(instantiate_job("* 0 0 1 * * *", conf.clone())) + .add(instantiate_job("0 0 0 1 * * *", conf.clone())) .unwrap(); } @@ -101,7 +110,6 @@ pub fn start_schedular(exit: Arc>) { fn instantiate_job<'a>(cron: &str, conf: SanitizedConf) -> Job { let job = Job::new(cron, move |_uuid, _l| { - // Setup minutes schedular if deadline is under 60 minutes update_wallpaper(&conf, false).unwrap(); }) .unwrap(); diff --git a/website/components/Nav.tsx b/website/components/Nav.tsx index a7da21c..2a7a167 100644 --- a/website/components/Nav.tsx +++ b/website/components/Nav.tsx @@ -1,33 +1,50 @@ import Image from "next/image"; -import React from "react"; +import React, { useEffect, useState } from "react"; import { Link } from "./Link"; export const Nav = () => { + const [openDrawer, setOpenDrawer] = useState(false); + + const OpenDrawerHandler = () => { + setOpenDrawer(!openDrawer); + }; + + useEffect(() => { + if (openDrawer) { + document.body.style.overflowY = "hidden"; + } else { + document.body.style.overflowY = "auto"; + } + }, [openDrawer]); + return (
-
); diff --git a/website/components/Section.tsx b/website/components/Section.tsx index fc246c3..e385c50 100644 --- a/website/components/Section.tsx +++ b/website/components/Section.tsx @@ -10,7 +10,7 @@ const Section: FC = ({ children, className, id }) => { return (
diff --git a/website/pages/Hero.tsx b/website/pages/Hero.tsx index 181fa03..f548fcf 100644 --- a/website/pages/Hero.tsx +++ b/website/pages/Hero.tsx @@ -6,7 +6,7 @@ const Hero = () => { return (
-

+

Say 👋 to procrastination
when you’re on a diff --git a/website/tailwind.config.js b/website/tailwind.config.js index 575a27a..374f753 100644 --- a/website/tailwind.config.js +++ b/website/tailwind.config.js @@ -5,6 +5,9 @@ module.exports = { ], theme: { extend: { + screens: { + lg: "1313px", + }, fontFamily: { Poppins: ["Poppins", "sans-serif"], },