feat(16-01): add upload success toast notification

- Add selectUploadStatus selector to track upload state transitions
- Track previous upload status with useRef
- Show toast.success when upload completes (uploading -> idle)
- Auto-dismiss after 3 seconds per REQ-5.4
- Success toast provides clear feedback on successful file uploads
This commit is contained in:
Nuwan 2026-02-06 18:42:35 +05:30
parent 9499934ea4
commit 354492bc1a
1 changed files with 12 additions and 1 deletions

View File

@ -55,7 +55,7 @@ import {
selectBackingTrackData,
selectJamTrackData
} from '../../store/features/activeSessionSlice';
import { addMessageFromWebSocket, uploadAttachment, selectIsUploading, selectUploadError, selectUploadFileName, clearUploadError } from '../../store/features/sessionChatSlice';
import { addMessageFromWebSocket, uploadAttachment, selectIsUploading, selectUploadError, selectUploadFileName, selectUploadStatus, clearUploadError } from '../../store/features/sessionChatSlice';
import { validateFile } from '../../services/attachmentValidation';
import { CLIENT_ROLE, RECORD_TYPE_AUDIO, RECORD_TYPE_BOTH } from '../../helpers/globals';
@ -203,6 +203,8 @@ const JKSessionScreen = () => {
const isUploading = useSelector(selectIsUploading);
const uploadError = useSelector(selectUploadError);
const uploadFileName = useSelector(selectUploadFileName);
const uploadStatus = useSelector(selectUploadStatus);
const prevUploadStatusRef = useRef(uploadStatus);
// File input ref for attach button
const attachFileInputRef = useRef(null);
@ -1048,6 +1050,15 @@ const JKSessionScreen = () => {
}
}, [uploadError, dispatch]);
// Show success toast when upload completes
useEffect(() => {
// Show success toast when upload transitions from 'uploading' to 'idle'
if (prevUploadStatusRef.current === 'uploading' && uploadStatus === 'idle') {
toast.success('File uploaded successfully', { autoClose: 3000 });
}
prevUploadStatusRef.current = uploadStatus;
}, [uploadStatus]);
const handleBackingTrackSelected = async (result) => {
console.log('JKSessionScreen: handleBackingTrackSelected called with:', result);
console.log('JKSessionScreen: Current state - showBackingTrackPopup:', showBackingTrackPopup, 'popupGuard:', popupGuard);