* feat: enhance schedule deletion to create a new schedule if none remain * feat: set active index to new schedule if only one exists * chore: run lint * feat: enhance schedule deletion to create a new schedule if none remain * feat: set active index to new schedule if only one exists * chore: run lint * feat: reset schedules on update, refactor invariant to within deleteSchedule * chore: pnpm lint --------- Co-authored-by: Samuel Gunter <29130894+Samathingamajig@users.noreply.github.com> Co-authored-by: Samuel Gunter <sgunter@utexas.edu>
22 lines
673 B
TypeScript
22 lines
673 B
TypeScript
import { ExtensionStore } from '@shared/storage/ExtensionStore';
|
|
import { UserScheduleStore } from '@shared/storage/UserScheduleStore';
|
|
|
|
import createSchedule from '../lib/createSchedule';
|
|
|
|
/**
|
|
* Called when the extension is updated (or when the extension is reloaded in development mode)
|
|
*/
|
|
export default async function onUpdate() {
|
|
await ExtensionStore.set({
|
|
version: chrome.runtime.getManifest().version,
|
|
lastUpdate: Date.now(),
|
|
});
|
|
|
|
const schedules = await UserScheduleStore.get('schedules');
|
|
|
|
// By invariant, there must always be at least one schedule
|
|
if (schedules.length === 0) {
|
|
createSchedule('Schedule 1');
|
|
}
|
|
}
|