Skip to content

Commit

Permalink
Add useDarkMode function
Browse files Browse the repository at this point in the history
  • Loading branch information
N0chteil committed May 28, 2022
1 parent 74de99c commit e4e1bb2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class AutoTheme {
private currentCronJob: cron.CronJob;
private location: Location;
private readonly store: ElectronStore;
private useDark: boolean;

constructor(func: (useDark: boolean) => void, store?: ElectronStore) {
this.newAutoTheme(func);
Expand Down Expand Up @@ -73,18 +74,27 @@ export class AutoTheme {
: sunset;

this.currentCronJob?.stop();
this.useDark = useDark;

func(useDark);

const cronJob = new cron.CronJob(cronDate, () => {
const now = new Date(),
useDark = now < sunrise || now >= sunset;

func(useDark);

this.useDark = useDark;

this.newAutoTheme(func);
});

cronJob.start();

this.currentCronJob = cronJob;
}

public useDarkMode() {
return this.useDark;
}
}

0 comments on commit e4e1bb2

Please sign in to comment.