Added scheduled off-work days
This commit is contained in:
@@ -92,9 +92,13 @@ export function patchDay(dateKey, patch) {
|
||||
return db.days.update(dateKey, patch);
|
||||
}
|
||||
|
||||
/** Create once, together with the first entry, even from competing tabs. */
|
||||
export function createDay(day, first) {
|
||||
return db.transaction('rw', db.days, db.entries, async () => {
|
||||
/** Create once. Automatic callers supply exclusions, checked again under lock. */
|
||||
export function createDay(day, first, nonWorkingDates = null) {
|
||||
return db.transaction('rw', db.days, db.entries, db.settings, async () => {
|
||||
if (nonWorkingDates != null) {
|
||||
const stored = await readSettings();
|
||||
if ((stored?.nonWorkingDates ?? nonWorkingDates).includes(day.date)) return false;
|
||||
}
|
||||
if (await getDay(day.date) || await getActiveDay()) return false;
|
||||
await db.days.add(day);
|
||||
await closeAndStart(day.date, day.startedTs, first);
|
||||
|
||||
Reference in New Issue
Block a user