* feat(build): inline chrome-extension-toolkit fix: tsconfig docs: add chrome-extension-toolkit README.md chore: update imports fix: stores fix: chrome-extension-toolkit ForegroundMessenger fix: calendarBackgroundHandler fix: format and lint fix: path alias fix: add jsdom env and fix imports Co-authored-by: Sriram Hariharan <sghsri@gmail.com> * build: vite storybook config crx toolkit line --------- Co-authored-by: Sriram Hariharan <sghsri@gmail.com> Co-authored-by: Derek <derex1987@gmail.com>
62 lines
2.5 KiB
TypeScript
62 lines
2.5 KiB
TypeScript
import { createSyncStore } from '@chrome-extension-toolkit';
|
|
|
|
/**
|
|
* A store that is used for storing user options
|
|
*/
|
|
export interface IOptionsStore {
|
|
/** whether we should enable course status chips (indicator for waitlisted, cancelled, and closed courses) */
|
|
enableCourseStatusChips: boolean;
|
|
|
|
/** whether we should automatically highlight conflicts on the course schedule page (adds a red strikethrough to courses that have conflicting times) */
|
|
enableHighlightConflicts: boolean;
|
|
|
|
/** whether we should automatically scroll to load more courses on the course schedule page (without having to click next) */
|
|
enableScrollToLoad: boolean;
|
|
|
|
/** whether we should automatically refresh the data for the waitlist, course status, and other info with the latest data from UT's site */
|
|
enableDataRefreshing: boolean;
|
|
|
|
/** whether we should open the calendar in a new tab; default is to focus an existing calendar tab */
|
|
alwaysOpenCalendarInNewTab: boolean;
|
|
|
|
/** whether the calendar sidebar should be shown when the calendar is opened */
|
|
showCalendarSidebar: boolean;
|
|
|
|
/** whether the promo should be shown */
|
|
showUTDiningPromo: boolean;
|
|
/** whether users are allowed to bypass the 10 schedule limit */
|
|
allowMoreSchedules: boolean;
|
|
}
|
|
|
|
export const OptionsStore = createSyncStore<IOptionsStore>('OptionsStore', {
|
|
enableCourseStatusChips: false,
|
|
enableHighlightConflicts: true,
|
|
enableScrollToLoad: true,
|
|
enableDataRefreshing: false,
|
|
alwaysOpenCalendarInNewTab: false,
|
|
showCalendarSidebar: true,
|
|
showUTDiningPromo: true,
|
|
allowMoreSchedules: false,
|
|
});
|
|
|
|
/**
|
|
* Initializes the settings by retrieving the values from the OptionsStore.
|
|
*
|
|
* @returns A promise that resolves to an object satisfying the IOptionsStore interface.
|
|
*/
|
|
export const initSettings = async () =>
|
|
({
|
|
enableCourseStatusChips: await OptionsStore.get('enableCourseStatusChips'),
|
|
enableHighlightConflicts: await OptionsStore.get('enableHighlightConflicts'),
|
|
enableScrollToLoad: await OptionsStore.get('enableScrollToLoad'),
|
|
enableDataRefreshing: await OptionsStore.get('enableDataRefreshing'),
|
|
alwaysOpenCalendarInNewTab: await OptionsStore.get('alwaysOpenCalendarInNewTab'),
|
|
showCalendarSidebar: await OptionsStore.get('showCalendarSidebar'),
|
|
showUTDiningPromo: await OptionsStore.get('showUTDiningPromo'),
|
|
allowMoreSchedules: await OptionsStore.get('allowMoreSchedules'),
|
|
}) satisfies IOptionsStore;
|
|
|
|
// Clothing retailer right
|
|
|
|
// debugStore({ OptionsStore });
|