Skip to content

Commit

Permalink
fix: schedule run at minutes left till the next hour
Browse files Browse the repository at this point in the history
  • Loading branch information
YassinEldeeb committed Apr 2, 2022
1 parent 46d0cf7 commit 68701f6
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 30 deletions.
File renamed without changes
22 changes: 15 additions & 7 deletions schedular/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ mod system_tray;
use std::{
env, fs,
sync::{Arc, Mutex},
time::Instant,
};

use chrono::{Local, NaiveDateTime};
Expand Down Expand Up @@ -51,26 +50,36 @@ pub fn start_schedular(exit: Arc<Mutex<bool>>) {
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();
}

Expand Down Expand Up @@ -101,7 +110,6 @@ pub fn start_schedular(exit: Arc<Mutex<bool>>) {

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();
Expand Down
59 changes: 38 additions & 21 deletions website/components/Nav.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<header className="w-full flex justify-center z-50 top-0 transition duration-200">
<nav className="flex justify-between items-center w-full py-4 lg:py-6 max-w-screen-2xl px-6 lg:px-12">
<nav className="flex justify-between items-center w-full py-6 max-w-screen-2xl px-8 lg:px-16">
<div className="cursor-pointer">
<Image src="/logo.svg" width={210} height={50} alt="Logo" />
</div>
<ul className="grow list-none flex justify-end">
<li className="mb-8 ml-10 lg:mb-0 ">
<Link href="/#features" text="Features" />
</li>
<li className="mb-8 ml-10 lg:mb-0 ">
<Link href="/#gallery" text="Gallery" />
</li>
<li className="mb-8 ml-10 lg:mb-0 ">
<Link href="/#motivation" text="Motivation" />
</li>
<li className="mb-8 ml-10 lg:mb-0 ">
<Link href="/#downloads" text="Downloads" />
</li>
</ul>
<a href="https://github.com/YassinEldeeb/Deadliner">
<div className="ml-10 w-8 h-8 hover:opacity-70 transition-all duration-100">
<Image src="/images/github.png" alt="" width={32} height={32} />
</div>
</a>

<div className="hidden lg:flex">
<ul className="grow list-none flex justify-end">
<li className="mb-8 ml-10 lg:mb-0 ">
<Link href="/#features" text="Features" />
</li>
<li className="mb-8 ml-10 lg:mb-0 ">
<Link href="/#gallery" text="Gallery" />
</li>
<li className="mb-8 ml-10 lg:mb-0 ">
<Link href="/#motivation" text="Motivation" />
</li>
<li className="mb-8 ml-10 lg:mb-0 ">
<Link href="/#downloads" text="Downloads" />
</li>
</ul>
<a href="https://github.com/YassinEldeeb/Deadliner">
<div className="ml-10 w-8 h-8 hover:opacity-70 transition-all duration-100">
<Image src="/images/github.png" alt="" width={32} height={32} />
</div>
</a>
</div>
</nav>
</header>
);
Expand Down
2 changes: 1 addition & 1 deletion website/components/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Section: FC<Props> = ({ children, className, id }) => {
return (
<div id={id || ""} className="flex justify-center">
<div
className={`w-full py-4 lg:py-6 max-w-screen-2xl px-6 lg:px-12 flex justify-center ${
className={`w-full py-4 lg:py-6 max-w-screen-2xl px-8 lg:px-16 flex justify-center ${
className ?? ""
}`}
>
Expand Down
2 changes: 1 addition & 1 deletion website/pages/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const Hero = () => {
return (
<div id="hero" className="flex justify-center items-center grow">
<Section className="flex-col items-center">
<h1 className="mb-20 text-white text-huge font-semibold text-center leading-[7.5rem] h-max">
<h1 className="mb-20 text-white lg:text-7xl xl:text-huge font-semibold text-center leading-[7.5rem] h-max">
Say 👋 to procrastination
<br />
when you’re on a
Expand Down
3 changes: 3 additions & 0 deletions website/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ module.exports = {
],
theme: {
extend: {
screens: {
lg: "1313px",
},
fontFamily: {
Poppins: ["Poppins", "sans-serif"],
},
Expand Down

1 comment on commit 68701f6

@vercel
Copy link

@vercel vercel bot commented on 68701f6 Apr 1, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.