@@ -14,6 +14,9 @@ import darkProfilePic from "../../assets/app/darkProfilePic.jpg";
1414import ftkProfilePic from "../../assets/app/ftk789ProfilePic.jpg" ;
1515import XLogo from "../../assets/logos/XLogo.svg?asset" ;
1616import kickLogoIcon from "../../assets/logos/kickLogoIcon.svg?asset" ;
17+ import NotificationFilePicker from "../Shared/NotificationFilePicker" ;
18+ import foldeOpenIcon from "../../assets/icons/folder-open-fill.svg?asset" ;
19+ import playIcon from "../../assets/icons/play-fill.svg?asset" ;
1720
1821const Settings = ( ) => {
1922 const { updateSettings, settings } = useSettings ( ) ;
@@ -55,6 +58,26 @@ const Settings = () => {
5558 }
5659 } ;
5760
61+ const [ notiFiles , setNotiFiles ] = useState ( [ ] ) ;
62+
63+ const getNotiFiles = useCallback ( async ( ) => {
64+ const files = await window . app . notificationSounds . getAvailable ( ) ;
65+ setNotiFiles (
66+ files . map ( ( file ) => ( {
67+ value : file . value ,
68+ label : file . name ,
69+ } ) ) ,
70+ ) ;
71+ return files . map ( ( file ) => ( {
72+ value : file . value ,
73+ label : file . name ,
74+ } ) ) ;
75+ } , [ ] ) ;
76+
77+ useEffect ( ( ) => {
78+ getNotiFiles ( ) ;
79+ } , [ getNotiFiles ] ) ;
80+
5881 const handleAddPhrase = useCallback (
5982 ( e ) => {
6083 const value = e . target . value . trim ( ) ;
@@ -642,6 +665,53 @@ const Settings = () => {
642665 </ div >
643666
644667 < div className = "settingsItem extended" >
668+ < div
669+ className = { clsx ( "settingSwitchItem" , {
670+ active : settingsData ?. notifications ?. background ,
671+ } ) } >
672+ < div className = "settingsItemTitleWithInfo" >
673+ < span className = "settingsItemTitle" > Notification Sound File</ span >
674+ < Tooltip delayDuration = { 100 } >
675+ < TooltipTrigger asChild >
676+ < button className = "settingsInfoIcon" >
677+ < img src = { InfoIcon } width = { 14 } height = { 14 } alt = "Info" />
678+ </ button >
679+ </ TooltipTrigger >
680+ < TooltipContent >
681+ < p > Select a custom audio file to play for notifications</ p >
682+ < p > You can add new files by pressing the folder icon and dragging your audio file there</ p >
683+ </ TooltipContent >
684+ </ Tooltip >
685+ </ div >
686+ < div >
687+ < button
688+ style = { { top : "0.5rem" , right : "10px" , position : "relative" } }
689+ onClick = { ( ) => {
690+ window . app . notificationSounds . openFolder ( ) ;
691+ } } >
692+ < img src = { foldeOpenIcon } > </ img >
693+ </ button >
694+ < button
695+ style = { { top : "0.5rem" , right : "10px" , position : "relative" } }
696+ onClick = { ( ) => {
697+ window . app . notificationSounds
698+ . getSoundUrl ( settings ?. notifications ?. soundFile )
699+ . then ( ( soundUrl ) => {
700+ const audio = new Audio ( soundUrl ) ;
701+ audio . volume = settings ?. notifications ?. volume || 0.1 ;
702+ audio . play ( ) . catch ( ( error ) => {
703+ console . error ( "Error playing sound:" , error ) ;
704+ } ) ;
705+ } )
706+ . catch ( ( error ) => {
707+ console . error ( "Error loading sound file:" , error ) ;
708+ } ) ;
709+ } } >
710+ < img src = { playIcon } > </ img >
711+ </ button >
712+ < NotificationFilePicker getOptions = { getNotiFiles } change = { changeSetting } settingsData = { settingsData } />
713+ </ div >
714+ </ div >
645715 < div
646716 className = { clsx ( "settingSwitchItem" , {
647717 active : settingsData ?. notifications ?. background ,
0 commit comments