Repository navigation
v0.2.4
BCFCODE v0.2.4 Release Notes
Welcome to BCFCODE v0.2.4 — a significant update focused on enhancing codebase structure, improving performance, and streamlining user management and state handling.
This release introduces a more modular architecture, Zustand for state management, and TanStack Query for efficient data fetching.
Below are the key changes, features, and improvements:
🚀 New Features
Zustand State Management
- Integrated Zustand for lightweight and performant global state management.
- Added
users.ts,leaderboard.ts, andcodewars.tsstores to centralize state logic. - Implemented actions for updating user data, Codewars challenges, and leaderboard status.
TanStack React Query Integration
- Adopted TanStack React Query for robust data fetching and caching.
- Prefetching user data in
Providers.tsxto enhance initial load performance. - Added React Query Devtools for easier debugging during development.
Improved Database Operations
- Enhanced
db.tswith new methods and transactional support:getCurrentUser: Fetches a single user with aggregated diamonds and Codewars data.addNewUser: Atomically creates a user with associated Codewars and diamonds records.connectCodewarsUserandreconnectCodewarsUser: Streamlined Codewars account linking with upsert support.resetDiamonds: Replaces diamond records for a user, ensuring consistency.
Refactored Layout and Providers
- Moved core app setup to
Providers.tsxfor better separation of concerns. - Consolidated session handling, navigation, branding, and query client setup.
- Improved hydration with
HydrationBoundaryfor seamless server-client transitions.
Enhanced Codewars Integration
- Simplified Codewars challenge handling:
- Removed
untrackedChallengesarray, replacing it with a booleanuntrackedChallengesAvailableflag. - Updated
currentUserReducerto support new actions:CHECK_UNTRACKED_CHALLENGES_AVAILABILITYADD_UNTRACKED_CHALLENGES_TO_LIST
- Removed
🛠️ Improvements
Codebase Restructuring
- Renamed and reorganized leaderboard-related files for clarity (e.g.,
Head/Header.tsx → UsersTable/Header.tsx). - Consolidated Codewars table components under
UsersTable/UserRow/Cells/CollapseButton/CodewarsTable. - Moved font definitions to
app/styles/fonts.tsfor consistency.
Performance Optimizations
- Optimized
useFilter.tsby removing unused hooks and simplifying logic. - Reduced redundant state updates in
useChallengesListEffect.tsanduseCollectedDiamondsEffect.ts. - Improved dependency arrays in hooks like
useCounterEffect.tsfor better React performance.
Error Handling and Robustness
- Enhanced transaction handling in
db.tswith proper session management and error logging. - Removed commented-out code and unused imports to reduce bundle size and improve readability.
UI/UX Enhancements
- Simplified tooltip logic in
Tooltips.tsxby commenting out unused functionality (preparing for future updates). - Improved theme consistency by updating font imports in
theme.ts.
🐛 Bug Fixes
- Fixed potential race conditions in database operations by using MongoDB transactions.
- Corrected import paths in renamed files to prevent runtime errors.
- Resolved issues with
useCollectedDiamondsEffect.tsby removing unnecessaryallUsersDispatchdependency. - Fixed commented-out code causing linting errors in
useMarkUntrackedChallenges.tsanduseUntrackedChallenges.ts.
🗑️ Removed Features
Deprecated Files and Hooks
- Removed
useMarkUntrackedChallenges.ts,useUntrackedChallenges.ts, and related tooltip components, replacing them with simplified logic in the Zustand store. - Deleted
Error.tsx,CodewarsSection,UsersMap.tsx, and other redundant leaderboard components. - Eliminated
useDispatchActions.tsas state management shifted to Zustand.
Simplified Untracked Challenges
- Dropped complex untracked challenge tracking in favor of a boolean flag, reducing state management overhead.
📚 Technical Details
Dependencies Added
@tanstack/react-query@^5.74.4@tanstack/react-query-devtools@^5.74.4zustand@^5.0.3
File Changes
- Added:
Providers.tsx,StoreInitializer.tsx,store/users.ts,store/leaderboard.ts,store/codewars.ts. - Renamed: Multiple leaderboard components for better organization.
- Modified:
db.ts,currentUserReducer.ts,layout.tsx, and various effects/hooks for compatibility with new state management.
Database Schema Updates
- Updated
CodewarsUsertype to useuntrackedChallengesAvailableboolean instead of an array. - Ensured upsert operations in database methods to handle edge cases.
🔧 Developer Notes
Migration Guide
- Update any components relying on old context providers (
AllUsersProvider,CurrentUserProvider) to use Zustand stores. - Replace manual data fetching with TanStack Query hooks where applicable.
- Remove references to deleted files and hooks.
Testing Recommendations
- Test database transactions thoroughly, especially
addNewUserandreconnectCodewarsUser. - Verify Zustand store updates in leaderboard and user management flows.
- Check TanStack Query caching behavior in production-like environments.
Known Issues
- Some commented-out code remains in
Tooltips.tsxanduseUntrackedChallenges.tsfor future iterations (to be addressed in v0.2.5). StoreInitializeris currently disabled; enable it after testing client-side hydration.
🌟 What's Next?
v0.2.5 Goals
- Fully enable
StoreInitializerfor client-side state initialization. - Reintroduce simplified tooltip functionality for untracked challenges.
- Add pagination support for Codewars challenges in the leaderboard.
- Enhance error handling with user-friendly UI feedback.
🙌 Contributors
- Bakhshandeh Morteza — Lead Developer
- BCFCODE Team — UI/UX and Testing Support
Thank you for using BCFCODE!
Join the coding battles and climb the leaderboard! 🚀