@@ -28,26 +28,6 @@ export default function Friends({ user, load, reset }: FriendsProps) {
2828 const [ isExpanded , setIsExpanded ] = useState ( false ) ;
2929 const [ matches , setMatches ] = useState < firebase . database . DataSnapshot > ( [ ] ) ;
3030 const [ searchResults , setSearchResults ] = useState < firebase . database . DataSnapshot > ( [ ] ) ;
31- const [ requestedNotifications , setRequestedNotifications ] = useState ( false ) ;
32-
33- // Request notification permission when Friends component mounts
34- useEffect ( ( ) => {
35- const requestPermission = async ( ) => {
36- if ( user && Notification . permission === 'default' && ! requestedNotifications ) {
37- console . log ( "Friends modal opened, attempting notification permission request..." ) ;
38- try {
39- const permission = await Notification . requestPermission ( ) ;
40- if ( permission === 'granted' )
41- saveFcmToken ( ) ;
42- } catch ( error ) {
43- console . error ( "Error requesting notification permission:" , error ) ;
44- } finally {
45- setRequestedNotifications ( true ) ;
46- }
47- }
48- } ;
49- requestPermission ( ) ;
50- } , [ user , requestedNotifications ] ) ;
5131
5232 // Synchronize Matches
5333 useEffect ( ( ) => {
@@ -171,6 +151,12 @@ export default function Friends({ user, load, reset }: FriendsProps) {
171151 Edit Profile
172152 </ a >
173153 </ li >
154+ { Notification . permission === 'default' ? < li >
155+ < a onPointerUp = { ( ) => saveFcmToken ( true ) } href = "#" >
156+ < span className = "material-icons notranslate" > notifications</ span >
157+ Notifications
158+ </ a >
159+ </ li > : null }
174160 < li >
175161 < a onPointerUp = { handleReset } href = "#" >
176162 < span className = "material-icons notranslate" > restart_alt</ span >
0 commit comments