@@ -120,10 +120,41 @@ export const ModerationNotifications: React.FC<ModerationNotificationsProps> = (
120120 setIsModalVisible ( true ) ;
121121 } catch ( error ) {
122122 console . error ( 'Failed to fetch event details:' , error ) ;
123- notificationController . error ( {
124- message : 'Failed to fetch event details' ,
125- description : error instanceof Error ? error . message : 'Unknown error'
126- } ) ;
123+
124+ // Check if this is a 400 error (event not found)
125+ if ( error instanceof Error && error . message . includes ( '400' ) ) {
126+ // Add this event ID to the list of non-existent events
127+ // This is done by accessing the module-level variable directly
128+ ( window as any ) . nonExistentEventIds = ( window as any ) . nonExistentEventIds || new Set < string > ( ) ;
129+ ( window as any ) . nonExistentEventIds . add ( eventId ) ;
130+
131+ // Show success message to the user
132+ notificationController . success ( {
133+ message : 'Notification removed' ,
134+ description : 'The notification was automatically removed because the referenced event no longer exists'
135+ } ) ;
136+
137+ // Try to delete on backend, but don't worry if it fails
138+ try {
139+ await deleteEvent ( eventId ) ;
140+ } catch ( deleteError ) {
141+ // Silently ignore the error since we're handling it locally
142+ console . log ( 'Backend delete failed, handling locally:' , deleteError ) ;
143+ }
144+
145+ // Refresh the notifications list to ensure our changes take effect
146+ fetchNotifications ( {
147+ page : pagination ?. currentPage || 1 ,
148+ limit : pagination ?. pageSize || 10 ,
149+ filter
150+ } ) ;
151+ } else {
152+ // For other errors, show the standard error message
153+ notificationController . error ( {
154+ message : 'Failed to fetch event details' ,
155+ description : error instanceof Error ? error . message : 'Unknown error'
156+ } ) ;
157+ }
127158 } finally {
128159 setIsEventLoading ( false ) ;
129160 }
0 commit comments