From ba4a2c0b7904b249acda4b51317e570160e3c975 Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Sat, 21 Dec 2024 13:03:32 +0100 Subject: [PATCH] fix: haptics --- components/PlayButton.tsx | 3 +++ components/common/TouchableItemRouter.tsx | 1 - components/video-player/controls/Controls.tsx | 5 +++-- hooks/useCreditSkipper.ts | 2 ++ hooks/useIntroSkipper.ts | 2 ++ 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/components/PlayButton.tsx b/components/PlayButton.tsx index 22b00324..e5c5dd87 100644 --- a/components/PlayButton.tsx +++ b/components/PlayButton.tsx @@ -32,6 +32,7 @@ import Animated, { import { Button } from "./Button"; import { SelectedOptions } from "./ItemContent"; import { chromecastProfile } from "@/utils/profiles/chromecast"; +import * as Haptics from "expo-haptics"; interface Props extends React.ComponentProps { item: BaseItemDto; @@ -78,6 +79,8 @@ export const PlayButton: React.FC = ({ const onPress = useCallback(async () => { if (!item) return; + Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); + const queryParams = new URLSearchParams({ itemId: item.Id!, audioIndex: selectedOptions.audioIndex?.toString() ?? "", diff --git a/components/common/TouchableItemRouter.tsx b/components/common/TouchableItemRouter.tsx index d23ddc6d..012739e1 100644 --- a/components/common/TouchableItemRouter.tsx +++ b/components/common/TouchableItemRouter.tsx @@ -66,7 +66,6 @@ export const TouchableItemRouter: React.FC> = ({ return ( { - Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); const url = itemRouter(item, from); // @ts-ignore router.push(url); diff --git a/components/video-player/controls/Controls.tsx b/components/video-player/controls/Controls.tsx index bd3ea18a..2f61929f 100644 --- a/components/video-player/controls/Controls.tsx +++ b/components/video-player/controls/Controls.tsx @@ -79,7 +79,7 @@ interface Props { setSubtitleURL?: (url: string, customName: string) => void; setSubtitleTrack?: (index: number) => void; setAudioTrack?: (index: number) => void; - stop?: (() => Promise) | (() => void); + stop: (() => Promise) | (() => void); isVlc?: boolean; } @@ -578,7 +578,8 @@ export const Controls: React.FC = ({ )} { - router.back(); + Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); + stop(); }} className="aspect-square flex flex-col bg-neutral-800/90 rounded-xl items-center justify-center p-2" > diff --git a/hooks/useCreditSkipper.ts b/hooks/useCreditSkipper.ts index 5f7a8b34..1430e7c9 100644 --- a/hooks/useCreditSkipper.ts +++ b/hooks/useCreditSkipper.ts @@ -5,6 +5,7 @@ import { apiAtom } from "@/providers/JellyfinProvider"; import { getAuthHeaders } from "@/utils/jellyfin/jellyfin"; import { writeToLog } from "@/utils/log"; import { msToSeconds, secondsToMs } from "@/utils/time"; +import * as Haptics from "expo-haptics"; interface CreditTimestamps { Introduction: { @@ -78,6 +79,7 @@ export const useCreditSkipper = ( if (!creditTimestamps) return; console.log(`Skipping credits to ${creditTimestamps.Credits.End}`); try { + Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); wrappedSeek(creditTimestamps.Credits.End); setTimeout(() => { play(); diff --git a/hooks/useIntroSkipper.ts b/hooks/useIntroSkipper.ts index 0cf15818..e6d28167 100644 --- a/hooks/useIntroSkipper.ts +++ b/hooks/useIntroSkipper.ts @@ -5,6 +5,7 @@ import { apiAtom } from "@/providers/JellyfinProvider"; import { getAuthHeaders } from "@/utils/jellyfin/jellyfin"; import { writeToLog } from "@/utils/log"; import { msToSeconds, secondsToMs } from "@/utils/time"; +import * as Haptics from "expo-haptics"; interface IntroTimestamps { EpisodeId: string; @@ -78,6 +79,7 @@ export const useIntroSkipper = ( console.log("skipIntro"); if (!introTimestamps) return; try { + Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light); wrappedSeek(introTimestamps.IntroEnd); setTimeout(() => { play();