-
-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Refactor/network #12
Merged
Merged
Conversation
This file contains 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
- Introduced a new `NetworkClient` class to handle network requests with support for authentication and error handling. - Created `NetworkEndpoint` protocol to define API endpoints, including methods for fetching and sending data. - Added specific endpoint implementations for various media types: `ItemEndpoints`, `ShelfEndpoints`, `TimelineEndpoints`, and `UserEndpoints`, enabling structured access to the API. - Enhanced error handling with custom `NetworkError` enum for better clarity in network operations. - Implemented query parameters and HTTP methods for each endpoint, ensuring flexibility in API interactions.
- Introduced a new `headers` property in the `NetworkEndpoint` protocol to allow custom HTTP headers for network requests. - Updated `NetworkClient` to set headers from the endpoint when making requests, enhancing flexibility in API interactions. - This change improves the ability to customize requests for various endpoints, supporting better integration with different APIs.
…ed error handling - Introduced a new `NetworkClient` to streamline network requests in `UserService`, replacing direct URLSession calls. - Updated `UserService` to utilize the `NetworkClient` for fetching user profiles, improving code organization and maintainability. - Enhanced error handling by logging detailed messages for unauthorized access and decoding errors. - Refactored `UserEndpoints` to define a clearer API path for fetching the current user profile. - Improved caching logic with debug logging for better tracking of user data retrieval and cache management.
- Introduced a new `UserUnauthorized` struct to handle unauthorized user responses, enhancing error management in user-related services. - Removed the unused `Endpoint.swift` file to streamline the codebase and eliminate redundancy.
…ency - Enhanced loading state management in ItemDetailView to provide clearer user feedback during data fetching. - Introduced a circular progress indicator overlay for better visual feedback during refresh states. - Updated ItemDetailViewModel to manage concurrent loading tasks effectively, ensuring previous tasks are canceled before new ones are initiated. - Standardized logging across various services and view models, improving clarity and consistency in logging practices. - Refined logging documentation to reflect new categories and best practices for better tracking and debugging.
… Client managers - Introduced `InstanceClient` and `OauthToken` structs to manage client and token data, enhancing the application's authentication capabilities. - Created `AccountManager` to handle user account management, including saving, deleting, and retrieving accounts securely using Keychain. - Developed `ClientManager` to manage instance client data, including saving and retrieving client information from Keychain, and registering clients with the server. - Added `InstanceManager` to manage the current instance and validate instance names, improving user experience and data integrity.
- Introduced `NewAuthService` to manage OAuth authentication flow, including app registration and token exchange. - Updated `OauthToken` model to use `Date` for `createdAt` and added custom coding keys for better JSON mapping. - Created `KeychainSwift` extension for potential keychain operations. - Modified `AuthEndpoints` to include a new `register` endpoint for app registration, enhancing the authentication process.
- Refactored `NetworkClient` to improve URL construction and request handling by introducing `makeURL` and `makeRequest` methods, enhancing code clarity and maintainability. - Updated endpoint paths in `AuthEndpoints`, `ItemEndpoints`, `ShelfEndpoints`, `TimelineEndpoints`, and `UserEndpoints` to remove the redundant `/api` prefix, aligning with the new API structure. - Improved error logging for URL construction failures, ensuring better debugging capabilities during network operations.
- Removed the deprecated `AppManager` class to streamline app management. - Introduced `AppRegisterClient` for handling app registration with external instances, including credential management and error handling. - Added `AppRegistrationResponse`, `InstanceClient`, and `OauthToken` models to support the new registration and authentication processes. - Enhanced error handling with specific cases for registration and authentication failures, improving robustness and user feedback.
- Introduced a new `NetworkEndpoint` protocol with improved properties for handling request body content type and default values. - Added `AppsEndpoints` to define app-related network operations, including a `create` endpoint with necessary query parameters. - Refactored `NetworkClient` to handle request body and content type more effectively, ensuring proper HTTP header management. - Improved code organization and clarity by separating endpoint definitions into dedicated files.
- Replaced manual URL construction in `AppRegisterClient` with a dedicated `NetworkClient` for improved request handling. - Updated `AppsEndpoints` to remove unnecessary parameters, streamlining the endpoint definition for app creation. - Enhanced error handling in the registration flow, providing more specific feedback for various network and response errors. - Improved code clarity and maintainability by consolidating registration logic and reducing redundancy.
- Added `AppRegisterClient` for managing app registration with external instances, including credential retrieval and storage. - Introduced `KeychainKeys` enum to streamline key management for account and client credentials. - Updated `AppAccount` to utilize the new keychain structure for generating account keys. - Enhanced `AppConfig` with a default instance URL for easier configuration.
- Renamed `AppRegisterClient` to `AppClient` and restructured the class to enhance credential management with methods for saving, retrieving, and deleting client credentials from the keychain. - Introduced static methods for retrieving all clients and registering new instances, streamlining the app registration process. - Added logging categories for better tracking of client-related operations. - Improved URL handling for instance management, ensuring robust key generation from instance URLs.
…r handling - Added logging functionality to AppAccount and AppClient for better tracking of account and client operations. - Refactored key management in AppAccount to improve key generation and error handling during save and retrieval processes. - Updated AppAccountsManager to ensure proper handling of current and available accounts, including error handling during account addition and deletion. - Enhanced AppClient with detailed logging for credential management, including registration and retrieval processes. - Improved overall code clarity and maintainability through consistent formatting and structure.
…nt usage - Replaced `AppRegistrationResponse` with `AppClientResponse` to better align with the updated data model. - Introduced a new `AppClientResponse` struct to encapsulate client details, including `id`, `name`, `website`, `redirectUri`, `clientId`, `clientSecret`, and `vapidKey`. - Updated `AppClient` and `AuthService` to utilize the new response structure, enhancing clarity and maintainability of the code. - Improved type safety and consistency in handling app registration responses.
… and initialization - Updated the AppClient struct to include additional properties: id, name, website, redirectUri, and vapidKey, enhancing its data encapsulation. - Introduced a new initializer in AppClient to streamline the creation process from AppClientResponse. - Renamed InstanceApp to AppClientResponse for clarity and consistency in naming conventions. - Removed the obsolete AppRegistrationResponse file, consolidating the response structure into AppClientResponse for better maintainability.
- Consolidated app registration logic by removing deprecated classes and improving the structure of the registration flow. - Enhanced error handling mechanisms to provide clearer feedback during registration and authentication processes. - Updated related models and protocols to ensure consistency and maintainability across the app registration framework.
…gistration handling - Renamed `AppClientResponse` to `AppsResponse` to better reflect the data structure used in app registration. - Updated `AppClient` to utilize the new `AppsResponse` type in its initializer and network fetch method, enhancing clarity and consistency. - Introduced `AppsResponse` struct to encapsulate app registration details, including `id`, `name`, `website`, and other relevant properties. - Improved type safety and maintainability in the app registration flow by aligning response handling with the updated data model.
- Introduced OAuth authentication flow in AppAccountsManager, including methods for generating authentication URLs and handling callbacks. - Added properties to track authentication state: isAuthenticated and isAuthenticating. - Implemented error handling and logging using OSLog for better tracking of authentication processes and errors. - Updated account management methods to reflect authentication status and improve error reporting during account addition and deletion.
…nt structure - Introduced a new ItemEndpoint enum to streamline endpoint definitions for various media types. - Removed the old ItemEndpoints enum, consolidating endpoint handling into a more flexible structure. - Enhanced path generation logic to accommodate different media types and their specific parameters, improving clarity and maintainability.
…sentation - Added Item.swift to define the base structure for various media types, including properties for title, description, and external resources. - Introduced ItemCategory.swift to categorize different media types such as book, movie, and podcast, improving organization and type safety. - Updated Models.swift to comment out previous model definitions, preparing for the new structure while maintaining backward compatibility.
…d schemas - Updated ItemSchema and related models to use snake_case for property names, enhancing consistency across the codebase. - Introduced new shared schemas: CrewMemberSchema, ExternalResourceSchema, and LocalizedTitleSchema to improve code organization and reusability. - Removed redundant coding keys in ItemSchema, simplifying the Codable conformance. - Enhanced overall maintainability and readability of the model definitions.
- Updated property names in ItemSchema and related models to use camelCase instead of snake_case, enhancing consistency across the codebase. - Removed redundant coding keys, simplifying the Codable conformance for better maintainability. - Ensured all media-related schemas (ItemSchema, EditionSchema, MovieSchema, TVShowSchema, etc.) follow the new naming convention. - Improved overall readability and organization of the model definitions.
- Introduced ShelfType.swift to define an enum representing different reading statuses: wishlist, progress, complete, and dropped. - Implemented displayName and systemImage properties for user-friendly representation of each status. - Enhanced code organization by encapsulating shelf-related logic within a dedicated model, improving maintainability and clarity.
…tructure - Introduced ItemProtocol to standardize properties across various media schemas, including ItemSchema, EditionSchema, MovieSchema, TVShowSchema, and others. - Updated media schemas to conform to ItemProtocol, ensuring consistent property definitions and enhancing code reusability. - Added a new ShelfType enum to categorize media statuses, providing user-friendly display names and system images. - Refactored HTMLContentView to utilize the new schema structure, improving data handling and initialization. - Enhanced overall organization and maintainability of the media-related models.
…tionality - Added MarkSchema.swift to define the structure for marking media items, including properties for shelf type, visibility, item details, creation time, comments, ratings, and tags. - Introduced PagedMarkSchema.swift to facilitate pagination of marked items, encapsulating an array of MarkSchema and pagination details. - Created ShelfType.swift to categorize media marking statuses with user-friendly display names and system images. - Updated ItemDetailService.swift to enhance caching and fetching mechanisms for media items, ensuring efficient data handling. - Refactored ItemActionsView.swift and HTMLContentView.swift to align with the new marking schema, improving UI integration and data representation.
- Added rawValue property to ItemCategory enum for better string representation of specific cases. - Introduced MarkInSchema struct to define the structure for marking items, including properties for shelf type, visibility, comments, ratings, and tags. - Created ShelfEndpoint enum to manage various shelf-related operations, including fetching shelves, marking items, and deleting marks. - Removed the outdated ShelfEndpoints enum to streamline endpoint management and improve code organization.
…patibility - Modified the JSONEncoder in ShelfEndpoint to use snake_case for key encoding, enhancing consistency with existing data structures. - This change ensures that the encoded data aligns with the expected format for API interactions, improving integration and data handling.
…d flexibility in API requests
… data handling - Refactored ItemDetailViewModel and LibraryViewModel to enhance data loading and error handling mechanisms. - Updated LibraryViewModel to utilize a cache service for improved performance and reduced network calls. - Introduced detailed error handling in LibraryViewModel to provide clearer feedback on loading issues. - Simplified the loading logic in both view models, ensuring better management of loading states and task cancellations. - Enhanced the integration of accounts management within LibraryViewModel for better user experience. - Improved the overall organization and maintainability of the view models, aligning with recent schema updates.
- Introduced debug logging capabilities in NetworkClient to log network requests and responses, improving traceability during development. - Updated ShelfEndpoint paths to include the "/me" prefix for better API structure and consistency in endpoint management. - Added dedicated loggers for network requests and responses to streamline logging practices across the application.
- Enhanced the query item handling in NetworkClient to filter out nil values, ensuring only valid query items are included in the URL. - Updated ShelfEndpoint to construct query items conditionally, allowing for better flexibility and cleaner API requests. - Removed unnecessary comments and improved code readability across the affected files.
…and LibraryViewModel - Introduced a dedicated method for logging decoding errors in NetworkClient, improving clarity and detail in error reporting. - Updated the date decoding strategy to ISO 8601 format for better compatibility with API responses. - Refactored logger initialization in LibraryViewModel to use the correct logger category for library views, ensuring consistent logging practices across the application.
…g strategy - Changed the type of createdTime in MarkSchema from Date to ServerDate for better alignment with server responses. - Removed the date decoding strategy from NetworkClient, simplifying the configuration and focusing on the new date handling approach. - Updated instances of MarkSchema in ShelfItemView to reflect the new createdTime type, ensuring consistency across the application.
- Changed the id property in MarkSchema to concatenate item.id with createdTime directly, simplifying the id generation logic. - This adjustment enhances clarity and aligns the id format with the new date handling approach introduced in previous commits.
- Removed commented-out code in ContentView for better clarity and maintainability. - Streamlined the initialization of LibraryViewModel in LibraryView by directly initializing the StateObject, enhancing code readability and reducing boilerplate.
- Introduced a new markdown file for LibraryView, detailing its components, data flow, caching strategy, and error handling. - Documented migration changes including error handling improvements, pagination support, caching for offline access, UI enhancements, and pull-to-refresh functionality. - Highlighted known issues related to date handling and item detail navigation for future reference.
…rity - Refactored ItemDetailService, ItemDetailView, ItemDetailViewModel, and ItemActionsView to enhance code organization and readability. - Removed commented-out code and unnecessary comments to streamline the implementation. - Improved caching logic and error handling in ItemDetailViewModel for better data management. - Updated ItemActionsView to ensure proper handling of external links and sharing functionality. - Enhanced overall maintainability and clarity across the ItemDetail module.
…aching - Updated ItemDetailView, ItemDetailViewModel, and ItemDetailViewContainer to support any ItemProtocol, enhancing type flexibility. - Refactored ItemDetailService to streamline item fetching and caching logic, ensuring better data management. - Improved error handling and loading states in ItemDetailViewModel for a more robust user experience. - Added background refresh capabilities to keep item details up-to-date. - Documented migration changes in a new markdown file, outlining key components and implementation details for future reference.
- Introduced a new URLHandler class to centralize URL processing for NeoDB, improving code organization and maintainability. - Updated HTMLContentView to utilize the new URLHandler for handling NeoDB URLs, streamlining the navigation logic. - Added a new logging category for services in the Logger to enhance logging capabilities related to URL handling. - Documented changes in ItemDetailView markdown, including migration from AuthService to AppAccountsManager for instance handling.
…d logging - Renamed method from handleNeoDBURL to handleItemURL to better reflect its functionality. - Enhanced URL parsing logic to utilize URLComponents for improved clarity and reliability. - Simplified path component validation and logging for better debugging. - Updated HTMLContentView to call the new handleItemURL method, ensuring consistent URL handling across the application.
- Improved URL parsing and logging in URLHandler, including the introduction of a debug logging mechanism. - Renamed identifier for clarity and streamlined path component validation. - Added special handling for TV seasons, episodes, and performance productions. - Removed redundant category handling method from HTMLContentView to centralize logic in URLHandler. - Introduced comprehensive documentation for URLHandler, detailing its functionality and migration changes.
…iner with direct ItemDetailView usage - Replaced ItemDetailViewContainer with direct instantiation of ItemDetailView in ContentView, enhancing clarity and reducing unnecessary complexity. - Updated ItemDetailView to utilize @StateObject for view model management, improving state handling. - Introduced ItemDetailState enum to manage loading, loaded, and error states more effectively. - Refactored ItemDetailView to separate content into ItemDetailContent, ItemDetailHeader, and ItemDetailActions components for better organization and maintainability. - Enhanced error handling and loading indicators within the ItemDetailView for improved user experience.
…re and naming conventions - Refactored ItemDetailView to ItemView, along with associated components and view models, enhancing clarity and maintainability. - Introduced ItemViewModel to manage item data loading, caching, and error handling more effectively. - Updated component structure by renaming and reorganizing ItemDetailHeader, ItemDetailActions, and ItemDetailContent into their respective components. - Implemented a robust caching strategy and improved error handling with user-friendly messages. - Documented migration changes in a new markdown file, outlining key components, data flow, and known issues for future reference.
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.
No description provided.