enh: option to toggle notification sound
Some checks are pending
Deploy to HuggingFace Spaces / check-secret (push) Waiting to run
Deploy to HuggingFace Spaces / deploy (push) Blocked by required conditions
Create and publish Docker images with specific build args / build-main-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-main-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-cuda-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/amd64) (push) Waiting to run
Create and publish Docker images with specific build args / build-ollama-image (linux/arm64) (push) Waiting to run
Create and publish Docker images with specific build args / merge-main-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-cuda-images (push) Blocked by required conditions
Create and publish Docker images with specific build args / merge-ollama-images (push) Blocked by required conditions
Python CI / Format Backend (3.11) (push) Waiting to run
Frontend Build / Format & Build Frontend (push) Waiting to run
Frontend Build / Frontend Unit Tests (push) Waiting to run
Integration Test / Run Cypress Integration Tests (push) Waiting to run
Integration Test / Run Migration Tests (push) Waiting to run

This commit is contained in:
Timothy Jaeryang Baek 2024-12-25 13:49:24 -07:00
parent 645313e321
commit 798886105e
2 changed files with 35 additions and 2 deletions

View File

@ -1,4 +1,5 @@
<script lang="ts">
import { settings } from '$lib/stores';
import DOMPurify from 'dompurify';
import { marked } from 'marked';
@ -11,8 +12,10 @@
export let content: string;
onMount(() => {
const audio = new Audio(`/audio/notification.mp3`);
audio.play();
if ($settings?.notificationSound ?? true) {
const audio = new Audio(`/audio/notification.mp3`);
audio.play();
}
});
</script>

View File

@ -32,6 +32,7 @@
let showUsername = false;
let richTextInput = true;
let largeTextAsFile = false;
let notificationSound = true;
let landingPageMode = '';
let chatBubble = true;
@ -81,6 +82,11 @@
saveSettings({ showUpdateToast: showUpdateToast });
};
const toggleNotificationSound = async () => {
notificationSound = !notificationSound;
saveSettings({ notificationSound: notificationSound });
};
const toggleShowChangelog = async () => {
showChangelog = !showChangelog;
saveSettings({ showChangelog: showChangelog });
@ -216,6 +222,8 @@
chatDirection = $settings.chatDirection ?? 'LTR';
userLocation = $settings.userLocation ?? false;
notificationSound = $settings.notificationSound ?? true;
hapticFeedback = $settings.hapticFeedback ?? false;
imageCompression = $settings.imageCompression ?? false;
@ -371,6 +379,28 @@
</div>
</div>
<div>
<div class=" py-0.5 flex w-full justify-between">
<div class=" self-center text-xs">
{$i18n.t('Notification Sound')}
</div>
<button
class="p-1 px-3 text-xs flex rounded transition"
on:click={() => {
toggleNotificationSound();
}}
type="button"
>
{#if notificationSound === true}
<span class="ml-2 self-center">{$i18n.t('On')}</span>
{:else}
<span class="ml-2 self-center">{$i18n.t('Off')}</span>
{/if}
</button>
</div>
</div>
{#if $user.role === 'admin'}
<div>
<div class=" py-0.5 flex w-full justify-between">