Skip to content

Commit 5514c75

Browse files
committed
Removing lots of console logging that isn't needed anymore
1 parent 2343aad commit 5514c75

File tree

8 files changed

+28
-122
lines changed

8 files changed

+28
-122
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
projectVersion=4.1.46
1+
projectVersion=4.1.47
22
org.gradle.configuration-cache=false

src/frontend/src/components/ContextMenu.tsx

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,17 @@ export function ContextMenu({
7878

7979
// Block if we just sent a request within the last 300ms
8080
if (now - lastUpdateTimeRef.current < 300) {
81-
console.log('Blocked duplicate API call (too soon)');
8281
return;
8382
}
8483

8584
// Block if this exact value was already sent
8685
if (lastSentValueRef.current === newValue) {
87-
console.log('Blocked duplicate API call (same value)');
8886
return;
8987
}
9088

9189
lastUpdateTimeRef.current = now;
9290
setIsUpdating(true);
9391

94-
console.log(`Calling API to update volume offset to ${newValue}%`);
95-
9692
try {
9793
const url = new URL(`${API_BASE_URL}/api/soundFiles/${soundId}`, window.location.origin);
9894
url.searchParams.append('volumeOffsetPercentage', newValue.toString());
@@ -107,17 +103,13 @@ export function ContextMenu({
107103
});
108104

109105
if (!response.ok) {
110-
console.error('Failed to update volume offset:', response.status, response.statusText);
111-
// Revert to original value on error
112106
setLocalVolumeOffset(volumeOffset ?? 0);
113107
toast.error('Failed to update volume offset');
114108
} else {
115109
lastSentValueRef.current = newValue;
116110
toast.success('Volume offset updated');
117111
}
118-
} catch (error) {
119-
console.error('Error updating volume offset:', error);
120-
// Revert to original value on error
112+
} catch {
121113
setLocalVolumeOffset(volumeOffset ?? 0);
122114
toast.error('Failed to update volume offset');
123115
} finally {
@@ -130,20 +122,14 @@ export function ContextMenu({
130122
};
131123

132124
const handleVolumeRelease = () => {
133-
console.log('handleVolumeRelease called');
134-
135-
// Only update if the value has changed from what we last sent
136125
if (localVolumeOffset !== lastSentValueRef.current) {
137126
updateVolumeOffset(localVolumeOffset);
138-
} else {
139-
console.log('No change in volume, skipping API call');
140127
}
141128
};
142129

143130
// Update display name on the backend
144131
const updateDisplayName = async (newName: string) => {
145132
setIsUpdatingName(true);
146-
console.log(`Calling API to update display name to: ${newName}`);
147133

148134
try {
149135
const url = new URL(`${API_BASE_URL}/api/soundFiles/${soundId}`, window.location.origin);
@@ -159,18 +145,13 @@ export function ContextMenu({
159145
});
160146

161147
if (!response.ok) {
162-
console.error('Failed to update display name:', response.status, response.statusText);
163-
// Revert to original value on error
164148
setEditedDisplayName(displayName || '');
165149
toast.error('Failed to update display name');
166150
} else {
167-
console.log('Display name updated successfully');
168151
setSavedDisplayName(newName);
169152
toast.success('Display name updated');
170153
}
171-
} catch (error) {
172-
console.error('Error updating display name:', error);
173-
// Revert to original value on error
154+
} catch {
174155
setEditedDisplayName(displayName || '');
175156
toast.error('Failed to update display name');
176157
} finally {

src/frontend/src/hooks/__tests__/useVolume.test.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ describe('useVolume', () => {
8080
})
8181

8282
it('handles API errors gracefully', async () => {
83-
const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
8483
;(global.fetch as any).mockRejectedValueOnce(new Error('Network error'))
8584

8685
const { result } = renderHook(() => useVolume())
@@ -89,10 +88,8 @@ describe('useVolume', () => {
8988
await result.current.updateVolume(80, 'user123')
9089
})
9190

92-
expect(result.current.volume).toBe(80) // Volume still updates locally
93-
expect(consoleErrorSpy).toHaveBeenCalledWith('Error updating volume:', expect.any(Error))
94-
95-
consoleErrorSpy.mockRestore()
91+
// Volume still updates locally even when API fails
92+
expect(result.current.volume).toBe(80)
9693
})
9794

9895
it('persists volume across remounts', () => {

src/frontend/src/hooks/usePlaybackTracking.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,7 @@ export function usePlaybackTracking({ selectedUserGuildId }: UsePlaybackTracking
5353
};
5454

5555
try {
56-
console.log('📡 Connecting to playback SSE endpoint:', API_ENDPOINTS.PLAYBACK_STREAM);
5756
playbackEventSource = new EventSource(API_ENDPOINTS.PLAYBACK_STREAM);
58-
59-
playbackEventSource.onopen = () => {
60-
console.log('✅ Playback SSE connection established');
61-
};
6257

6358
playbackEventSource.onerror = () => {
6459
// Let EventSource auto-reconnect silently
@@ -68,31 +63,28 @@ export function usePlaybackTracking({ selectedUserGuildId }: UsePlaybackTracking
6863
if (!isMounted) return;
6964
try {
7065
const data = JSON.parse(event.data);
71-
console.log('🎵 Track started:', data);
7266
handleTrackStart(data);
73-
} catch (error) {
74-
console.error('Error parsing trackStart event:', error);
67+
} catch {
68+
// Ignore parse errors
7569
}
7670
});
7771

7872
playbackEventSource.addEventListener('trackEnd', (event) => {
7973
if (!isMounted) return;
8074
try {
8175
const data = JSON.parse(event.data);
82-
console.log('🎵 Track ended:', data);
8376
handleTrackEnd(data);
84-
} catch (error) {
85-
console.error('Error parsing trackEnd event:', error);
77+
} catch {
78+
// Ignore parse errors
8679
}
8780
});
88-
} catch (error) {
89-
console.error('Failed to create playback SSE connection:', error);
81+
} catch {
82+
// SSE connection failed, will retry on next mount
9083
}
9184

9285
return () => {
9386
isMounted = false;
9487
if (playbackEventSource) {
95-
console.log('🧹 Closing playback SSE connection');
9688
playbackEventSource.close();
9789
}
9890
};

src/frontend/src/hooks/useSoundActions.ts

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {

src/frontend/src/hooks/useSounds.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,16 @@ export function useSounds() {
7171
}
7272
});
7373

74-
console.log('🔄 SSE Update - Favorites from backend:', Array.from(newFavorites));
75-
console.log('🔄 SSE Update - Total sounds received:', transformedSounds.length);
76-
console.log('🔄 SSE Update - Favorited sounds:', transformedSounds.filter(s => s.favorite).map(s => ({ id: s.id, favorite: s.favorite })));
77-
7874
setFavorites(newFavorites);
7975
setLoading(false);
8076
setConnectionStatus('connected');
8177
};
8278

8379
try {
84-
console.log('📡 Connecting to SSE endpoint:', API_ENDPOINTS.SOUNDS_STREAM);
8580
eventSource = new EventSource(API_ENDPOINTS.SOUNDS_STREAM);
86-
81+
8782
eventSource.onopen = () => {
8883
if (!isMounted) return;
89-
console.log('✅ SSE connection established');
9084
setConnectionStatus('connected');
9185
};
9286

src/frontend/src/hooks/useVolume.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@ export function useVolume() {
3939
);
4040

4141
if (!response.ok) {
42-
console.error('Failed to update volume:', response.status);
43-
} else {
44-
console.log(`Volume updated successfully: ${newVolume}%`);
42+
// Volume update failed silently
4543
}
46-
} catch (error) {
47-
console.error('Error updating volume:', error);
44+
} catch {
45+
// Volume update failed silently
4846
}
4947
};
5048

0 commit comments

Comments
 (0)