@@ -26,23 +26,17 @@ export function useSoundActions({
2626 const toggleFavorite = async ( soundId : string ) => {
2727 const isFavorite = favorites . has ( soundId ) ;
2828 const newFavoriteState = ! isFavorite ;
29- const callId = Math . random ( ) . toString ( 36 ) . substring ( 7 ) ;
30-
29+
3130 if ( toggleFavoriteInProgressRef . current . has ( soundId ) ) {
32- console . log ( `[${ callId } ] toggleFavorite called for ${ soundId } , but a toggle is already in progress` ) ;
3331 return ;
3432 }
35-
33+
3634 toggleFavoriteInProgressRef . current . add ( soundId ) ;
37-
35+
3836 try {
39- console . log ( `[${ callId } ] toggleFavorite called for ${ soundId } , changing to ${ newFavoriteState } ` ) ;
40- console . trace ( `[${ callId } ] Call stack` ) ;
41-
42- console . log ( `[${ callId } ] About to call fetch...` ) ;
4337 const response = await fetch (
4438 `${ API_ENDPOINTS . FAVORITE } /${ soundId } ?favorite=${ newFavoriteState } ` ,
45- {
39+ {
4640 method : 'POST' ,
4741 mode : 'cors' ,
4842 credentials : 'include' ,
@@ -52,10 +46,8 @@ export function useSoundActions({
5246 }
5347 }
5448 ) ;
55- console . log ( `[${ callId } ] Fetch completed, response received` ) ;
5649
5750 if ( ! response . ok ) {
58- console . error ( `[${ callId } ] Failed to update favorite status:` , response . status ) ;
5951 throw new Error ( 'Failed to update favorite status' ) ;
6052 }
6153
@@ -66,22 +58,17 @@ export function useSoundActions({
6658 await response . clone ( ) . text ( ) . catch ( ( ) => { } ) ;
6759 }
6860
69- console . log ( `[${ callId } ] Favorite status updated successfully: ${ newFavoriteState } ` ) ;
70-
71- console . log ( `[${ callId } ] Updating local favorites state...` ) ;
7261 setFavorites ( prev => {
7362 const newFavorites = new Set ( prev ) ;
7463 if ( newFavoriteState ) {
7564 newFavorites . add ( soundId ) ;
76- console . log ( `[${ callId } ] Added ${ soundId } to favorites. New favorites:` , Array . from ( newFavorites ) ) ;
7765 } else {
7866 newFavorites . delete ( soundId ) ;
79- console . log ( `[${ callId } ] Removed ${ soundId } from favorites. New favorites:` , Array . from ( newFavorites ) ) ;
8067 }
8168 return newFavorites ;
8269 } ) ;
8370 } catch ( error ) {
84- console . error ( `[ ${ callId } ] Error updating favorite status:` , error ) ;
71+ console . error ( ' Error updating favorite status:' , error ) ;
8572 toast . error ( 'Failed to update favorite. Please try again.' , { duration : 3000 } ) ;
8673 } finally {
8774 toggleFavoriteInProgressRef . current . delete ( soundId ) ;
@@ -111,15 +98,11 @@ export function useSoundActions({
11198 ) ;
11299
113100 if ( ! response . ok ) {
114- const errorText = await response . text ( ) . catch ( ( ) => 'Unknown error' ) ;
115- console . error ( `Failed to play sound through bot: ${ response . status } - ${ errorText } ` ) ;
116101 throw new Error ( `Failed to play sound through bot: ${ response . status } ` ) ;
117102 }
118103
119- console . log ( 'Sound played successfully through bot' ) ;
120104 setCurrentlyPlayingSoundId ( soundId ) ;
121105 } catch ( error ) {
122- console . error ( 'Error playing sound through bot:' , error ) ;
123106 if ( error instanceof TypeError || ( error instanceof Error && error . message . includes ( 'Failed to play' ) ) ) {
124107 if ( error instanceof TypeError ) {
125108 toast . error ( 'Failed to play sound. Please make sure the backend is running' , { duration : 3000 } ) ;
@@ -148,14 +131,9 @@ export function useSoundActions({
148131 ) ;
149132
150133 if ( ! response . ok ) {
151- const errorText = await response . text ( ) . catch ( ( ) => 'Unknown error' ) ;
152- console . error ( `Failed to play random sound: ${ response . status } - ${ errorText } ` ) ;
153134 throw new Error ( `Failed to play random sound: ${ response . status } ` ) ;
154135 }
155-
156- console . log ( 'Random sound played successfully' ) ;
157136 } catch ( error ) {
158- console . error ( 'Error playing random sound:' , error ) ;
159137 if ( error instanceof TypeError ) {
160138 toast . error ( 'Failed to play random sound. Please make sure the backend is running' , { duration : 3000 } ) ;
161139 } else if ( error instanceof Error ) {
@@ -182,15 +160,11 @@ export function useSoundActions({
182160 ) ;
183161
184162 if ( ! response . ok ) {
185- const errorText = await response . text ( ) . catch ( ( ) => 'Unknown error' ) ;
186- console . error ( `Failed to stop sound: ${ response . status } - ${ errorText } ` ) ;
187163 throw new Error ( `Failed to stop sound: ${ response . status } ` ) ;
188164 }
189165
190- console . log ( 'Sound stopped successfully' ) ;
191166 setCurrentlyPlayingSoundId ( null ) ;
192167 } catch ( error ) {
193- console . error ( 'Error stopping sound:' , error ) ;
194168 if ( error instanceof TypeError ) {
195169 toast . error ( 'Failed to stop sound. Please make sure the backend is running' , { duration : 3000 } ) ;
196170 } else if ( error instanceof Error ) {
@@ -206,7 +180,6 @@ export function useSoundActions({
206180 } ) ;
207181
208182 if ( ! response . ok ) {
209- console . error ( 'Failed to delete sound:' , response . status , response . statusText ) ;
210183 toast . error ( 'Failed to delete sound' , { duration : 3000 } ) ;
211184 return ;
212185 }
@@ -219,8 +192,7 @@ export function useSoundActions({
219192 } ) ;
220193
221194 toast . success ( 'Sound deleted successfully' , { duration : 3000 } ) ;
222- } catch ( error ) {
223- console . error ( 'Error deleting sound:' , error ) ;
195+ } catch {
224196 toast . error ( 'Failed to delete sound' , { duration : 3000 } ) ;
225197 }
226198 } ;
@@ -256,8 +228,6 @@ export function useSoundActions({
256228 formData . append ( 'file' , file ) ;
257229
258230 try {
259- console . log ( '📤 Uploading file:' , file . name ) ;
260-
261231 const authHeaders = getAuthHeadersWithCsrf ( ) ;
262232
263233 const response = await fetch ( API_ENDPOINTS . UPLOAD , {
@@ -275,17 +245,12 @@ export function useSoundActions({
275245 }
276246
277247 if ( ! response . ok ) {
278- const errorText = await response . text ( ) . catch ( ( ) => 'Unknown error' ) ;
279- console . error ( `Failed to upload file: ${ response . status } - ${ errorText } ` ) ;
280248 throw new Error ( `Failed to upload file: ${ response . status } ` ) ;
281249 }
282250
283- console . log ( '✅ File uploaded successfully' ) ;
284251 toast . success ( `File "${ file . name } " uploaded successfully!` , { duration : 3000 } ) ;
285-
286252 event . target . value = '' ;
287253 } catch ( error ) {
288- console . error ( 'Error uploading file:' , error ) ;
289254 if ( error instanceof TypeError ) {
290255 toast . error ( 'Failed to upload file. Please make sure the backend is running' , { duration : 3000 } ) ;
291256 } else if ( error instanceof Error ) {
0 commit comments