Skip to content
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

Apply Coordinator Pattern and Add Deep-Links #155

Merged
merged 25 commits into from
Oct 2, 2021

Conversation

PangMo5
Copy link
Member

@PangMo5 PangMo5 commented Aug 21, 2021

With the Coordinator pattern,

  • Helps to single-responsibility principle (SRP).
  • It collects scattered navigation processing codes into one place.
  • Makes the View lighter.
  • etc...

Coordinators

  • ConnectToServerCoodinator
  • HomeCoordinator
  • LibraryListCoordinator
  • MainCoordinator
  • MainTabCoordinator
  • SearchCoordinator
  • SettingsCoordinator
  • LibraryCoordinator
  • ItemCoordinator
  • FilterCoordinator
  • VideoPlayerCoordinator

Deep-Links

  • jellyfin://Users/{UserID}/Items/{ItemID}

Feel free to leave any advice on the current structure!

Add ConnectToServerCoodinator
Add HomeCoordinator
Add LibraryListCoordinator
Add MainCoordinator
Add MainTabCoordinator
@PangMo5 PangMo5 added the enhancement New feature or request label Aug 21, 2021
@PangMo5 PangMo5 self-assigned this Aug 21, 2021
@PangMo5 PangMo5 linked an issue Aug 21, 2021 that may be closed by this pull request
@PangMo5 PangMo5 changed the title Apply Coordinator Patterns and Add Deep-Links Apply Coordinator Pattern and Add Deep-Links Aug 21, 2021
@LePips
Copy link
Member

LePips commented Aug 21, 2021

This work looks great! Are you referencing any articles or tutorials for this?

We need to make some contribution and developer docs for this project so that us and other contributors know what architectures are being used and what we have discussed and decided upon. We don't want someone in the future re-writing all of this on their own.

@PangMo5
Copy link
Member Author

PangMo5 commented Aug 21, 2021

This work looks great! Are you referencing any articles or tutorials for this?

I'm currently using https://github.com/rundfunk47/stinsen and referencing on an example and docs of that project.

I think if you look at Swiftfin's code after the work is complete, you can easily understand the action and structure of each coordinator.

@acvigue
Copy link
Member

acvigue commented Aug 23, 2021

looks great!

@LePips
Copy link
Member

LePips commented Aug 24, 2021

@PangMo5 dont mean to bug, have you done any more work on this? I want to do view model refactoring after this. If your branch is up to date, I can help work on this if you would like. If not, that's okay

@PangMo5
Copy link
Member Author

PangMo5 commented Aug 24, 2021

@PangMo5 dont mean to bug, have you done any more work on this? I want to do view model refactoring after this. If your branch is up to date, I can help work on this if you would like. If not, that's okay

First, the branch is up to date.

But I'll proceed for now. It won't take too long.
I'll mention it if I need help. Thanks.

Add LibraryCoordinator
Add SearchCoordinator
Add SettingsCoordinator
Update HomeCoordinator
Update LibraryListCoordinator
@PangMo5 PangMo5 linked an issue Aug 25, 2021 that may be closed by this pull request
@PangMo5
Copy link
Member Author

PangMo5 commented Aug 25, 2021

The current implementation is complete, but the Coordinator has many duplicate codes and DeepLink does not work as expected.

I created related question in Stinsen project.

@PangMo5 PangMo5 marked this pull request as ready for review August 25, 2021 11:22
@PangMo5 PangMo5 requested a review from acvigue as a code owner August 25, 2021 11:22
@PangMo5
Copy link
Member Author

PangMo5 commented Aug 25, 2021

For now, I'm changed a PR state to get advice.

@LePips
Copy link
Member

LePips commented Aug 25, 2021

I see the discussion going on in your issue and that he needs to do some work with a coordinator in a navigation stack.

If this satisfies the needs for deep linking, I'm good with and support this work. I'm okay with the duplicate code here since it's due to a protocol.

Shared/Singleton/AppURLHandler.swift Outdated Show resolved Hide resolved
Shared/Singleton/AppURLHandler.swift Outdated Show resolved Hide resolved
Shared/ViewModels/ConnectToServerViewModel.swift Outdated Show resolved Hide resolved
JellyfinPlayer.xcodeproj/project.pbxproj Show resolved Hide resolved
JellyfinPlayer/SettingsView.swift Show resolved Hide resolved
@PangMo5
Copy link
Member Author

PangMo5 commented Aug 25, 2021

If this satisfies the needs for deep linking, I'm good with and support this work. I'm okay with the duplicate code here since it's due to a protocol.

I need to think more about the deep link structure :(
I'd appreciate your help!

@PangMo5 PangMo5 marked this pull request as draft August 25, 2021 18:08
@PangMo5 PangMo5 marked this pull request as ready for review September 21, 2021 20:28
@PangMo5
Copy link
Member Author

PangMo5 commented Sep 21, 2021

I don't see widgets in my simulator, maybe it's a simulator's problem.
If you can, please check whether the deep-link is working properly in widgets.

@PangMo5 PangMo5 requested a review from LePips September 21, 2021 20:36
LePips
LePips previously approved these changes Sep 21, 2021
let userID = url.pathComponents[safe: 1],
let itemID = url.pathComponents[safe: 3]
{
// It would be nice if the ItemViewModel could be initialized to id later.
Copy link
Member

Choose a reason for hiding this comment

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

I will keep this in mind when I refactor how we handle media.

@LePips
Copy link
Member

LePips commented Sep 21, 2021

I don't see widgets in my simulator, maybe it's a simulator's problem.
If you can, please check whether the deep-link is working properly in widgets.

You have to search for the app and Jellyfin will be a result. Just a bug of the simulator.

@PangMo5
Copy link
Member Author

PangMo5 commented Sep 21, 2021

You have to search for the app and Jellyfin will be a result. Just a bug of the simulator.

I can't find it :(

스크린샷 2021-09-22 오전 5 48 24

@LePips
Copy link
Member

LePips commented Sep 21, 2021

I can't find it :(

That's strange, try the iOS 15 simulator. The search is working for me there

@PangMo5
Copy link
Member Author

PangMo5 commented Sep 21, 2021

That's strange, try the iOS 15 simulator. The search is working for me there

It's the same in 15 🤔
If you see the widgets, please test it :p

@LePips
Copy link
Member

LePips commented Sep 21, 2021

Sorry, I'm going to have to take back my approval. The app is crashing upon signing out. This is because of a forced bang on our SessionManager object (which we shouldn't necessarily use and that I am refactoring).

However, the app is trying to build SettingsView again after signing out, which is where the crash is occurring.

@LePips
Copy link
Member

LePips commented Sep 21, 2021

Ignore last comment. In the meantime, do a:

                    if let user = SessionManager.current.user {
                        Text(user.username ?? "")
                            .foregroundColor(.jellyfinPurple)
                    }

in SettingsView, starting on line 34.

As I have said, I'll fix all Session/server/user stuff.

@PangMo5
Copy link
Member Author

PangMo5 commented Sep 21, 2021

Interestingly, it seems to be a problem in only iOS 15. lol
Anyway I'll fix it.

@LePips
Copy link
Member

LePips commented Sep 21, 2021

Interestingly, it seems to be a problem in only iOS 15. lol
Anyway I'll fix it.

Oh, that is interesting. Sounds good to me

LePips
LePips previously approved these changes Sep 21, 2021
@LePips
Copy link
Member

LePips commented Sep 21, 2021

Widgets work great on their own and are bugged out a little bit because of, guess what, the way we handle sessions/server/user. This doesn't stop the work here from being merged.

# Conflicts:
#	JellyfinPlayer.xcodeproj/project.pbxproj
#	JellyfinPlayer.xcworkspace/xcshareddata/swiftpm/Package.resolved
@sonarcloud
Copy link

sonarcloud bot commented Sep 23, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 41 Code Smells

No Coverage information No Coverage information
1.2% 1.2% Duplication

@LePips LePips self-requested a review September 23, 2021 21:11
@LePips
Copy link
Member

LePips commented Sep 30, 2021

@acvigue Could this either be merged or I be given permission to merge? I think having this work in so that jhays can implement it in tvOS would be great.

Copy link
Member

@anthonylavado anthonylavado left a comment

Choose a reason for hiding this comment

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

Approving based on comment from @LePips.

@anthonylavado anthonylavado merged commit 084f96b into main Oct 2, 2021
@PangMo5 PangMo5 deleted the PangMo5/coordinator-and-deep-link branch October 2, 2021 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Next Up Widget View route improvement and deep-linking support
4 participants