Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions components/inbox-mail/types-mail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ export type InboxMailThread = {
}
}

export type Settings = {
soundName?: string;
enabled?: boolean;
onlyForLongTasks: boolean;
onlyIfNotInFocus: boolean;
}


export type User = {
id: string;
organizationId: string;
Expand All @@ -52,6 +60,8 @@ export type User = {
logoutUrl: string;
isAdmin: boolean;
autoLogoutMinutes: number;
soundSettings: Settings;
notificationSettings: Settings;
}


Expand Down
14 changes: 14 additions & 0 deletions hooks/useSound.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useRef } from "react";

export function useSound(volume = 1) {
const audioRef = useRef<HTMLAudioElement | null>(null);

const play = (src: string) => {
if (!src) return;
audioRef.current = new Audio(src);
audioRef.current.volume = volume;
audioRef.current.play().catch(() => { });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a warning/error in the console if it doesn't work.

also do we need to wrap it in a useCallback? otherwiese the function reference might change on every render

};

return play;
}