fix(ui): duplicate schedule warning (#295)
* fix(ui): duplicate schedule warning * fix(ui): duplicate schedule warning * fix(ui): duplicate schedules * fix(ui): schedule limit loophole refactored * fix(ui): schedule bypass hooks * fix(ui): useEnforceScheduleLimit hook created * fix(ui): added useCallback to hook * fix(ui): updated jsdoc comment on hook * fix(ui): updated jsdoc comments on hook
This commit is contained in:
@@ -7,6 +7,7 @@ import { openReportWindow } from '@shared/util/openReportWindow';
|
||||
import Divider from '@views/components/common/Divider';
|
||||
import List from '@views/components/common/List';
|
||||
import Text from '@views/components/common/Text/Text';
|
||||
import { useEnforceScheduleLimit } from '@views/hooks/useEnforceScheduleLimit';
|
||||
import useSchedules, { getActiveSchedule, replaceSchedule, switchSchedule } from '@views/hooks/useSchedules';
|
||||
import { getUpdatedAtDateTimeString } from '@views/lib/getUpdatedAtDateTimeString';
|
||||
import useKC_DABR_WASM from 'kc-dabr-wasm';
|
||||
@@ -62,6 +63,13 @@ export default function PopupMain(): JSX.Element {
|
||||
// const [isRefreshing, setIsRefreshing] = useState(false);
|
||||
const [funny, setFunny] = useState<string>('');
|
||||
|
||||
const enforceScheduleLimit = useEnforceScheduleLimit();
|
||||
const handleAddSchedule = () => {
|
||||
if (enforceScheduleLimit()) {
|
||||
createSchedule('New Schedule');
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const randomIndex = Math.floor(Math.random() * splashText.length);
|
||||
setFunny(
|
||||
@@ -128,7 +136,7 @@ export default function PopupMain(): JSX.Element {
|
||||
variant='filled'
|
||||
color='ut-burntorange'
|
||||
className='h-fit p-0 btn'
|
||||
onClick={() => createSchedule('New Schedule')}
|
||||
onClick={handleAddSchedule}
|
||||
>
|
||||
<AddSchedule className='h-6 w-6' />
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user