bunch of misc changes
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import React from 'react';
|
||||
import { bMessenger } from 'src/shared/messages';
|
||||
import { background } from 'src/shared/messages';
|
||||
import useSchedules from '../hooks/useSchedules';
|
||||
import { Button } from './common/Button/Button';
|
||||
import ExtensionRoot from './common/ExtensionRoot/ExtensionRoot';
|
||||
|
||||
const { clearCourses } = bMessenger;
|
||||
export default function PopupMain() {
|
||||
const [activeSchedule, schedules] = useSchedules();
|
||||
|
||||
@@ -15,7 +14,7 @@ export default function PopupMain() {
|
||||
<Button
|
||||
onClick={() => {
|
||||
if (!activeSchedule) return;
|
||||
clearCourses({ scheduleName: activeSchedule?.name });
|
||||
background.clearCourses({ scheduleName: activeSchedule?.name });
|
||||
}}
|
||||
>
|
||||
Clear Courses
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import classNames from 'classnames';
|
||||
import React, { PropsWithChildren } from 'react';
|
||||
import { bMessenger } from 'src/shared/messages';
|
||||
import { background } from 'src/shared/messages';
|
||||
import Text, { TextProps } from '../Text/Text';
|
||||
import styles from './Link.module.scss';
|
||||
|
||||
@@ -20,7 +20,7 @@ export default function Link(props: PropsWithChildren<Props>) {
|
||||
const { url } = props;
|
||||
|
||||
if (url && !props.onClick) {
|
||||
passedProps.onClick = () => bMessenger.openNewTab({ url });
|
||||
passedProps.onClick = () => background.openNewTab({ url });
|
||||
}
|
||||
const isDisabled = props.disabled || (!url && !props.onClick);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { bMessenger } from 'src/shared/messages';
|
||||
import { background } from 'src/shared/messages';
|
||||
import { Course } from 'src/shared/types/Course';
|
||||
import { UserSchedule } from 'src/shared/types/UserSchedule';
|
||||
import { Button } from 'src/views/components/common/Button/Button';
|
||||
@@ -13,7 +13,7 @@ type Props = {
|
||||
course: Course;
|
||||
};
|
||||
|
||||
const { openNewTab, addCourse, removeCourse } = bMessenger;
|
||||
const { openNewTab, addCourse, removeCourse } = background;
|
||||
|
||||
/**
|
||||
* This component displays the buttons for the course info popup, that allow the user to either
|
||||
|
||||
20
src/views/hooks/useVersion.ts
Normal file
20
src/views/hooks/useVersion.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Serialized } from 'chrome-extension-toolkit';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { ExtensionStore } from 'src/shared/storage/ExtensionStore';
|
||||
|
||||
export default function useVersion(): string {
|
||||
const [version, setVersion] = useState<string>('');
|
||||
|
||||
useEffect(() => {
|
||||
const listener = ExtensionStore.listen('version', ({ newValue }) => {
|
||||
setVersion(newValue);
|
||||
});
|
||||
|
||||
return () => {
|
||||
ExtensionStore.removeListener(listener);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return version;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import React from 'react';
|
||||
import { background } from 'src/shared/messages';
|
||||
import render from './lib/react';
|
||||
|
||||
import { ContextInvalidated, createShadowDOM, isExtensionPopup, onContextInvalidated } from 'chrome-extension-toolkit';
|
||||
@@ -14,6 +15,11 @@ if (!support) {
|
||||
throw new Error('UT Registration Plus does not support this page, even though it should...');
|
||||
}
|
||||
|
||||
// if we are in an iframe, throw an error
|
||||
if (window.self !== window.top) {
|
||||
throw new Error('inside an iframe');
|
||||
}
|
||||
|
||||
if (support === SiteSupport.EXTENSION_POPUP) {
|
||||
render(<PopupMain />, document.getElementById('root'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user