From 55097410f6457b2a6f7b2e0022f49615b133852d Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Wed, 14 Aug 2024 17:05:43 +0200 Subject: [PATCH] feat: haptic feedback on support devices (android) Co-Authored-By: Danny Liu --- src/lib/components/chat/Chat.svelte | 8 ++++++ .../components/chat/Settings/Interface.svelte | 28 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index a290d5d3d..64b51be96 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -877,6 +877,10 @@ } else { responseMessage.content += data.message.content; + if (navigator.vibrate && ($settings?.hapticFeedback ?? false)) { + navigator.vibrate(5); + } + const sentences = extractSentencesForAudio(responseMessage.content); sentences.pop(); @@ -1177,6 +1181,10 @@ } else { responseMessage.content += value; + if (navigator.vibrate && ($settings?.hapticFeedback ?? false)) { + navigator.vibrate(5); + } + const sentences = extractSentencesForAudio(responseMessage.content); sentences.pop(); diff --git a/src/lib/components/chat/Settings/Interface.svelte b/src/lib/components/chat/Settings/Interface.svelte index d5e198890..58de9be4c 100644 --- a/src/lib/components/chat/Settings/Interface.svelte +++ b/src/lib/components/chat/Settings/Interface.svelte @@ -34,6 +34,7 @@ let showEmojiInCall = false; let voiceInterruption = false; + let hapticFeedback = false; const toggleSplitLargeChunks = async () => { splitLargeChunks = !splitLargeChunks; @@ -70,6 +71,11 @@ saveSettings({ voiceInterruption: voiceInterruption }); }; + const toggleHapticFeedback = async () => { + hapticFeedback = !hapticFeedback; + saveSettings({ hapticFeedback: hapticFeedback }); + }; + const toggleUserLocation = async () => { userLocation = !userLocation; @@ -151,6 +157,8 @@ chatDirection = $settings.chatDirection ?? 'LTR'; userLocation = $settings.userLocation ?? false; + hapticFeedback = $settings.hapticFeedback ?? false; + defaultModelId = $settings?.models?.at(0) ?? ''; if ($config?.default_models) { defaultModelId = $config.default_models.split(',')[0]; @@ -438,6 +446,26 @@ +
+
+
{$i18n.t('Haptic Feedback')}
+ + +
+
+
{$i18n.t('Voice')}