Skip to content

Refactor and Enhance Identity Configuration Flow #159

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

Merged
merged 47 commits into from
Jan 15, 2025
Merged

Conversation

rdas-ditto
Copy link
Contributor

@rdas-ditto rdas-ditto commented Nov 12, 2024

Closes TOOLS-299

This PR started as a fix for the issue of tools crashing on AppleTV hardware (https://github.com/getditto/DittoSwiftTools/issues/153), but has evolved into a more significant refactor to improve the Identity Configuration flow, resulting in a more flexible, maintainable, and user-centered experience. I’m opening this PR now to invite feedback on the current direction, even as final work on some components is still underway. Early review and comments will help refine this approach further.

Changes in Scope

The changes touch several areas:
Identity Configuration Service: Centralized identity management responsibilities, streamlining keychain interactions and making activeConfiguration handling more robust.
Form Refactoring: Broke down the form into more modular components (IdentityForm, IdentityFormInputView, etc.), enabling a more adaptable UI that changes based on the identity type selected.
Validation and Supplementary Fields: Added support for identity-specific fields and supplementary credentials (e.g., AuthDelegate details) in the form, with validation and input management centralized within the ViewModel.
Error Handling and Sync State Management: Improved error handling with dedicated DittoServiceError cases, better encapsulating sync state and managing initialization flows.

Key Changes

DittoService: Refined to distinguish between identity setup and sync management, now using distinct methods for initializing, starting, and stopping the sync engine.
Configuration Data Flow: Moved identity and supplementary data persistence into the ConfigurationService, with Keychain integration for storage and retrieval.
View Structure: Updated ConfigurationView to encapsulate form data binding and apply consistent identity configuration handling across iOS and tvOS.
Delegates: Enhanced AuthDelegate integration to interact seamlessly with ConfigurationService, reducing duplicate identity configuration code.

Still in Progress

UI Adjustments: Fine-tuning visual aspects of the form, especially on tvOS, to better align with system conventions.
Validation and Error Messaging: Additional UI messaging for invalid configurations, with further error handling around sync restarts.

Next Steps

Testing: I’ll continue testing each identity configuration type and sync state management in various scenarios, especially around error and edge cases.
Further Review: Any feedback on architecture, naming, or potential simplifications would be highly appreciated at this stage.

Thanks for taking a look early. I’m excited to hear any thoughts and adjust as needed!

- Resolved crash on tvOS hardware
- DittoManager initializes with platform-specific persistenceDirectory
- Refactored Login → ConfigurationView
- Updated UI for ConfigurationView to enable easier pasting of credentials
# Conflicts:
#	DittoToolsApp/DittoToolsApp/Views/MenuListItem.swift
@rdas-ditto rdas-ditto requested a review from a team as a code owner November 12, 2024 19:39
Copy link
Member

@bplattenburg bplattenburg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is huge! both literally and in terms of impact, thanks for taking the time to do the deeper dive.

- Refactored the Identity Form, now with added Validation!
- Separated some types and enums into their own files, for clarity.
- Added DittoServiceError type.
- Added code docs and comments for Identity Configuration and Supplementary Credentials.
- Restored LoggingDetailsView to working order.
- Updated ExportData to help distinguish it from ExportLogs.
Copy link

linear bot commented Dec 11, 2024

@rdas-ditto rdas-ditto marked this pull request as draft December 11, 2024 15:12
…y with the new changes.

- LoggingDetailsView now directly manipulates the DittoLogger attached to the ditto instance, rather than manipulating a passed Binding. This improves encapsulation and ensures that anyone can use this to easily visualize (and change) their Log level at runtime in their app, without having to create any new logic.
- updated Readme
- removed references to DittoLogger+LoggingOptions which is now replaced by an extension on DittoLogLevel instead.
- removed published log level tool, as the ExportLogs tool manipulates DittoLogger directly, to improve encapsulation and remove dependency.
- added more documentation
- improved error handling and throwing
- migrated persistenceDirectoryURL logic to an extension, and made it throw
- applied Swift Formatting
- Added an animated SyncButton that both indicates the sync status of the Ditto engine, and allows it to be toggled.
- improved destroyDittoInstance logic, ensuring everything is shut down correctly.
- moved PersistenceDirectory extension into its own file.
- Used ViewBuilders to simplify the logic for multiplatform (tvOS vs. everything else) layout, to make the view easier to understand.
- Resolved a logic issue where the logic for applyConfiguration had to be passed into the Form. This is now handled consistently across all platforms.
- Improved the separation of concerns by moving the implementation of services out of the Framework, and into the App layer.
- Sources/AllToolsMenu → DittoToolsApp/MenuView
- Refactored ToolsList → AllToolsMenu
- removed unused classes, stale code
- Updated App Icon to current Ditto Logo
- “DittoToolsApp” → “Ditto Tools”
- Added tvOS assets (app can now be released to the App Store)
- Refactored params from SupplementalCredentials to be part of the Credentials object, which now holds a Ditto Identity, plus the other properties.
- Simplifies KeychainService significantly, since now we’re only storing one object.

NOTE: If you have previously installed the tools app on a device, and it stored credentials (ie. an older version from this branch), you may experience a crash.
- Moved tab bar item logic to parent ContentView
- Simplified MenuView implementation
- ContentView now managed showing/hiding CredentialsView
Copy link
Collaborator

@ErikEverson ErikEverson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work on this!! It has a lot of utilities that I had to build into the Pluto app on top. This will be great.

# Refactored Identity Configuration Flow

- **Renamed key components for clarity and consistency:**
  - `Identity Form` → `Credentials View`
  - `IdentityFormInputView` → `Form Field`
  - `FormInputData` → `Form State`

- **Reorganized view responsibilities:**
  - `CredentialsView` now handles `Apply`, `Cancel`, and `Clear` button actions and injects them into the `FormView`.
  - `FormView` focuses exclusively on rendering form fields dynamically based on the `Form State`.

- **Documentation improvements:**
  - Added comprehensive DocC and comments for all cleaned-up and refactored objects.
# Conflicts:
#	DittoToolsApp/DittoToolsApp.xcodeproj/project.pbxproj
#	README.md
@rdas-ditto rdas-ditto marked this pull request as ready for review January 7, 2025 19:59
@bplattenburg bplattenburg requested a review from a team January 7, 2025 20:00
@rdas-ditto
Copy link
Contributor Author

PR: Significant Refactor of Ditto Tools App

Overview

This PR introduces a significant refactor of the Ditto Tools App. The focus has been on the "All Tools" menu and the surrounding architecture. The individual tools themselves have not been altered, except for "Export Logs", which required changes to ensure compatibility.

Goals of This PR

The refactor is aimed at improving clarity, maintainability, and usability of the codebase. Key changes include:

  • Reorganization of the All Tools Menu.
  • Refinement of the Export Logs tool to ensure it works seamlessly with the refactored structure.
  • Comprehensive testing on various devices and configurations.

What I’d Like You to Do

  1. Check out the codebase.
  2. Verify that it builds and runs immediately with no changes.
  3. Test the app:
    • Input some credentials and confirm the app behaves as expected.
    • Start and stop the sync engine, ensuring functionality is smooth.
    • Try the app on a variety of devices and simulators.
  4. Kick the tires! Explore edge cases and regular use cases.
  5. Note any bugs or issues:
    • Are there any rough edges?
    • As a user, is the app clear and straightforward to navigate?
    • Any suggestions for edits or alterations?

Feedback Needed

  • Bugs or issues you encounter.
  • Suggestions for improving usability or clarity.
  • General impressions: If you were a customer using this, would it make sense?

Looking forward to your feedback and suggestions!

Copy link
Member

@bplattenburg bplattenburg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome work, just saw a few minor things to talk through

Copy link
Member

@bplattenburg bplattenburg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@rdas-ditto rdas-ditto merged commit b0893de into main Jan 15, 2025
@rdas-ditto rdas-ditto deleted the fix/153-apple-tv branch January 15, 2025 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants