Fix: Performance bottlenecks, large library handling, and time formatting#4
Open
Mahmoud-walid wants to merge 33 commits into
Open
Fix: Performance bottlenecks, large library handling, and time formatting#4Mahmoud-walid wants to merge 33 commits into
Mahmoud-walid wants to merge 33 commits into
Conversation
- set up prettier code formatting with eslint and VSCode integration - add expo-camera for QR code scanning to connect to the AIMP server - add new npm scripts for development, building, and code checks - update project configurations including app permissions, EAS project ID, and TS config - refactor config files and README tables for better readability
add generate-full-project-content.ts for full project scans, and generate-folder-content.ts for targeted directory scans, excluding common ignored paths and files, and limiting processed file size to 2MB
restructure theme module to use unified Colors object, remove default export, fix trailing newline
use react-native-reanimated for looping fade animation, accept custom dimensions, border radius and theme props
add TypeScript prop typing using SvgProps, condense JSX syntax, use single quotes consistently and remove redundant SVG namespace attributes
Fix PlaylistStatsProps artists and genres from object[] to string[] Standardize indentation for all type interface properties Add missing trailing newlines to all type definition files Add new PlaylistItemType interface for playlist items
Add full theme support to the app settings context, including system theme detection via React Native's useColorScheme, persist theme preference to AsyncStorage, update context types to include theme state and setters, improve the useSettings hook to throw an error when used outside its provider, fix import quote consistency, indentation and missing newline at end of file, translate Spanish console errors to English, and update default server ip to empty string.
- add console warning for websocket JSON parse errors - add typed AIMPState interface and use SongInterface for track data - add early exit if server IP is missing to prevent invalid WebSocket connections - add safe WebSocket ref cleanup and proper TypeScript types for the ref - standardize all string quotes to single quotes across the file - fix initial volumeState value to match the defined nullable type
standardize import quotes to single quotes, fix indentation, clean up JSX and style formatting, add missing trailing newline
Reformat the entire header component to use consistent 2-space indentation, double quotes for strings, and proper semicolon placement. Add optional chaining to optional setter props to avoid runtime TypeErrors when they are not passed by parent components.
provide two connection methods: manual IP entry and QR code scanning. handle both plain IP text and JSON formatted QR codes containing the server IP, manage camera permission requests for QR mode, save server connection details to the app settings, navigate back to the home screen after a successful connection, and include animated UI transitions for a smoother user experience.
Clean up JSX and styles formatting, fix inconsistent indentation across the component, and add missing trailing newline.
Fix stale closure issues in the animation useEffect by including required dependencies. Reformat all code and JSX for improved readability, and add missing trailing newline to the file.
fix indentation, standardize quote usage, correct useSettings hook placement, add missing trailing newline and improve overall readability without altering functionality
- replace generic object/any props with proper PlaylistItemType for better type safety - replace hardcoded text and separator colors with theme-aware values from app context - standardize import quotes, format code and fix missing trailing newline
standardize quote styles, enforce uniform indentation, clean up spacing and fix trailing file newline
reformat entire file for consistent indentation, quotes, trailing commas, semicolons, and end-of-file newline
- Replace Android-exclusive ToastAndroid with cross-platform Alert for save feedback - Update all hardcoded styling colors to use the app's theme system - Remove unused imports and commented code - Format component and style code for improved readability
- add proper PlaylistItemType typing for playlist items state - fix index type mismatch in play item onPress handler - wrap handlePlayItem and renderItem with useCallback for performance - add loading fallback for FlatList header and required Text import - clean up code formatting and standardize indentation
standardize indentation, add trailing semicolons, prettify JSX structure, and fix missing trailing newline in the file
…ading Add dynamic theming using app settings across all screens Add auto-redirect to connect screen when no server IP is configured Implement responsive playlist grid on home screen Add loading skeleton states during playlist data fetch Improve navigation animations, styling and error handling
Add `build-on-arch` npm script for cross-architecture remote builds Install required dev dependencies: ts-node and @types/node Standardize LF line endings across the repository via .gitattributes and editor settings Update Prettier configuration to enforce LF line endings Enable auto-format on save for VS Code Add "type": "module" to package.json for ES module support Add initial README for the remote build script Fix package.json script formatting
This script syncs required project files to a pre-configured Arch Linux remote host via SCP, runs an optimized Android build remotely, then installs and launches the resulting APK via Waydroid. It handles SIGINT cleanup for stopping the running app and includes convenient log viewing commands.
- add explicit TypeScript type to aimpEvent state - rewrite state update logic to only trigger re-renders when actual values change - add floor check for position updates to avoid spurious small position changes - remove unused ToastAndroid import and showToast helper function - simplify websocket error handler by removing unused event parameter - replace error toast with console.warn for parsing errors
converts millisecond inputs to padded time strings, returns 00:00 for invalid or zero values, and formats output as either MM:SS or HH:MM:SS based on total duration
update PlaylistItemType and SongInterface interfaces to include the new optional fields
render a full-screen connection failure view with themed styling, animated fade-in entrance, and a retry button to trigger reconnection attempts. include helpful hints about ensuring AIMP and the Web Control Plugin are running on the host computer.
- Add fallback display title that uses title → name → cleaned filename, defaults to 'Unknown' - Show 'Unknown Artist' when artist metadata is missing - Replace manual duration formatting with formatTimeHelper utility - Condense style definitions in playlistSongItem
extend search matching to use song.name, and extract base filename from path as last resort for display title
…gging - simplify unused fetch response handling - fix unit mismatches for song position and duration tracking - update sliders to use onSlidingComplete to reduce excessive API calls - improve song title display with fallback to filename or unknown - condense inline styles and remove dead code - add consistent console.warn error logging - use formatTimeHelper for standardized time formatting
Combine parallel playlist API calls into a single Promise.all to reduce network overhead. Add offline state tracking to detect network failures, render the OfflineScreen component when offline, and include a retry button for data fetching. Remove unused ToastAndroid import and showToast helper function. Conditionally hide the TogglePlayer component when offline. Clean up redundant style definitions and inline JSX to improve code readability.
Author
|
@ReitanSora I will send a video after I'm completely finished |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR introduces critical performance optimizations and UI/UX fixes, specifically targeting issues encountered when handling large music libraries, long-duration tracks, and network disconnections.
Key Fixes & Improvements
WebSocket Performance & Crash Fix
Fixed a critical bug where the app would crash with a "Maximum update depth exceeded" error. The issue was caused by the WebSocket sending position updates multiple times per second, triggering infinite re-renders. The
useAIMPhook now properly filters these updates, only updating the state when the integer value of the second changes.Support for Large Folders (Missing Metadata Fallback)
When loading very large folders (e.g., 5GB+), AIMP processes metadata in the background. Previously, this resulted in massive lists showing "Unknown" for tracks that hadn't been fully scanned yet. UI components (
TogglePlayer,PlaylistItem,[id].tsx, andindex.tsxof the player) now implement a fallback logic: it attempts to displaytrack.title, falling back totrack.name, and finally extracting the file name fromtrack.filename.Long Track Time Formatting
Fixed an issue where tracks longer than an hour (e.g., 1.5 hours) were incorrectly displayed as 30 minutes. Replaced the
toISOString().slice(14, 19)method with a customformatTimeHelperutility that properly calculates and formats hours, minutes, and seconds.Slider Lag Optimization
The player slider caused severe app lagging and overwhelmed the server with requests because it used
onValueChangeto send position/volume data on every micro-movement. This has been updated to useonSlidingComplete, sending a single request only when the user releases the slider. Time unit conversions (millis to seconds) were also corrected for the API payload.Cross-Platform Stability
Removed all instances of
ToastAndroidfrom background hooks and components. These calls were unsafe and would cause hard crashes on iOS devices. They have been replaced with safeconsole.warnlogging and UI-driven error handling.Offline UX Implementation
Instead of relying on toast messages or failing silently, the app now features a dedicated
OfflineScreencomponent. If the initial fetch fails (e.g., the AIMP PC app is closed or the network is down), the user is presented with a clear offline state and a "Retry Connection" button, significantly improving the user experience.Testing Performed
Related: #3