1
0
Fork 0

s/allowNofitications/allowNotifications

Also very embarrassing
This commit is contained in:
Lim Chee Aun 2024-01-17 11:32:16 +08:00
parent b6c4045cb4
commit 3fbd5b8622

View file

@ -643,7 +643,7 @@ function PushNotificationsSection({ onClose }) {
const { instance } = api(); const { instance } = api();
const [uiState, setUIState] = useState('default'); const [uiState, setUIState] = useState('default');
const pushFormRef = useRef(); const pushFormRef = useRef();
const [allowNofitications, setAllowNotifications] = useState(false); const [allowNotifications, setAllowNotifications] = useState(false);
const [needRelogin, setNeedRelogin] = useState(false); const [needRelogin, setNeedRelogin] = useState(false);
const previousPolicyRef = useRef(); const previousPolicyRef = useRef();
useEffect(() => { useEffect(() => {
@ -689,7 +689,7 @@ function PushNotificationsSection({ onClose }) {
ref={pushFormRef} ref={pushFormRef}
onChange={() => { onChange={() => {
const values = Object.fromEntries(new FormData(pushFormRef.current)); const values = Object.fromEntries(new FormData(pushFormRef.current));
const allowNofitications = !!values['policy-allow']; const allowNotifications = !!values['policy-allow'];
const params = { const params = {
policy: values.policy, policy: values.policy,
data: { data: {
@ -718,9 +718,13 @@ function PushNotificationsSection({ onClose }) {
}); });
const policyChanged = previousPolicyRef.current !== params.policy; const policyChanged = previousPolicyRef.current !== params.policy;
console.log('PN Form', { values, allowNofitications, params }); console.log('PN Form', {
values,
allowNotifications: allowNotifications,
params,
});
if (allowNofitications && alertsCount > 0) { if (allowNotifications && alertsCount > 0) {
if (policyChanged) { if (policyChanged) {
console.debug('Policy changed.'); console.debug('Policy changed.');
removeSubscription() removeSubscription()
@ -754,7 +758,7 @@ function PushNotificationsSection({ onClose }) {
type="checkbox" type="checkbox"
disabled={isLoading || needRelogin} disabled={isLoading || needRelogin}
name="policy-allow" name="policy-allow"
checked={allowNofitications} checked={allowNotifications}
onChange={async (e) => { onChange={async (e) => {
const { checked } = e.target; const { checked } = e.target;
if (checked) { if (checked) {
@ -778,7 +782,7 @@ function PushNotificationsSection({ onClose }) {
Allow from{' '} Allow from{' '}
<select <select
name="policy" name="policy"
disabled={isLoading || needRelogin || !allowNofitications} disabled={isLoading || needRelogin || !allowNotifications}
> >
{[ {[
{ {
@ -803,7 +807,7 @@ function PushNotificationsSection({ onClose }) {
style={{ style={{
width: '100%', width: '100%',
}} }}
hidden={!allowNofitications} hidden={!allowNotifications}
> >
<div class="shazam-container-inner"> <div class="shazam-container-inner">
<div class="sub-section"> <div class="sub-section">