I made the requested changes that were listed in the issue. I believe I made the code a bit cleaner and a bit more maintainable. You guys could probably make it even more modularized but this is okay for now. Let me know what you guys think.
My changes are ⬇️:
1. LocationContext
Modularized Location Management:
Extracted location fetching logic into a dedicated service (locationService.ts), removing it from the context to adhere to separation of concerns.
Simplified the LocationProvider to handle only state management, with the location fetching and permissions logic handled by external services.
2. SettingsContext
Refactored Settings Handling:
Moved theme loading and saving logic to a utility file (storageUtils.ts), separating storage concerns from context management.
Simplified SettingsProvider by initializing the state through utility functions and directly handling the toggle logic without redundant state reloading.
3. SocketContext
Modularized Socket Logic:
Moved socket initialization to a dedicated service (SocketService.ts) that handles the setup and connection of the Socket.IO client.
Moved token retrieval logic to a the SocketService, centralizing the authentication concerns.
Refactored location update emission also to SocketService, isolating the responsibility of sending location updates to the server.
4. UserContext
Modularized User Initialization:
Moved the user initialization logic, including generateName() and the default user object setup, to a separate service file (UserService.ts).
Simplified UserProvider by using the initializeUser function from the service to set the default state directly.
Closes #235
Hey,
I made the requested changes that were listed in the issue. I believe I made the code a bit cleaner and a bit more maintainable. You guys could probably make it even more modularized but this is okay for now. Let me know what you guys think.
My changes are ⬇️:
1. LocationContext
2. SettingsContext
3. SocketContext
4. UserContext