Added a guest haptics preference and surfaced it in both the settings sheet and /settings, with safe device detection

and a reduced‑motion guard. Haptics now honor the toggle and still fall back gracefully on iOS (switch disabled when
  navigator.vibrate isn’t available).

  What changed

  - Haptics preference storage + gating: resources/js/guest/lib/haptics.ts
  - Preference hook: resources/js/guest/hooks/useHapticsPreference.ts
  - Settings UI toggle in sheet + page: resources/js/guest/components/settings-sheet.tsx, resources/js/guest/pages/
    SettingsPage.tsx
  - i18n labels: resources/js/guest/i18n/messages.ts
  - Tests: resources/js/guest/lib/__tests__/haptics.test.ts
This commit is contained in:
Codex Agent
2025-12-27 14:00:12 +01:00
parent 3e3a2c49d6
commit fa5a1fa367
11 changed files with 241 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ import { notify } from '../queue/notify';
import { useTranslation } from '../i18n/useTranslation';
import { isGuestDemoModeEnabled } from '../demo/demoMode';
import { useEventData } from './useEventData';
import { triggerHaptic } from '../lib/haptics';
type DirectUploadResult = {
success: boolean;
@@ -106,6 +107,7 @@ export function useDirectUpload({ eventToken, taskId, emotionSlug, onCompleted }
if (taskId) {
markCompleted(taskId);
}
triggerHaptic('success');
try {
const raw = localStorage.getItem('my-photo-ids');
@@ -121,6 +123,7 @@ export function useDirectUpload({ eventToken, taskId, emotionSlug, onCompleted }
return { success: true, photoId, warning };
} catch (err) {
console.error('Direct upload failed', err);
triggerHaptic('error');
const uploadErr = err as UploadError;
const meta = uploadErr.meta as Record<string, unknown> | undefined;
const dialog = resolveUploadErrorDialog(uploadErr.code, meta, (v: string) => v);