Skip to content

Commit

Permalink
Fix navigator.vibrate check, address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
GovernmentPlates committed Jul 18, 2024
1 parent ed589c2 commit 73bd348
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/pages/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ function MainSettings() {
hapticFeedback,
setHapticFeedback,
} = useSettings();
console.log('hapticFeedback', typeof hapticFeedback);

const toggleDarkMode = () => {
// Set the theme preference in localStorage and in the SettingsContext
Expand Down
4 changes: 2 additions & 2 deletions src/pages/participant/ParticipantPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function ParticipantPageContent({
});
}
}
}, [participant, errorModal]);
}, [participant, errorModal, hapticFeedback]);

const accompanyingPersons = useMemo(() => {
if (participant?.registrationData) {
Expand Down Expand Up @@ -161,7 +161,7 @@ function ParticipantPageContent({
} finally {
}
},
[offline, errorModal, soundEffect]
[offline, errorModal, soundEffect, hapticFeedback]
);

useEffect(() => {
Expand Down
6 changes: 3 additions & 3 deletions src/utils/haptics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const patterns = {
clear: [0],
};

export function vibrate(pattern: number[]) {
if (!navigator.vibrate || !navigator.userActivation.isActive) {
function vibrate(pattern: number[]) {
if (!('vibrate' in navigator) || !navigator.userActivation.isActive) {
console.warn('Haptics not supported!');
return;
}

navigator.vibrate(pattern);
return navigator.vibrate(pattern);
}

export const playVibration = {
Expand Down

0 comments on commit 73bd348

Please sign in to comment.