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

[feat] Downloads/Uploads manager usage simplification and sample unification #59

Merged
merged 14 commits into from
Jan 23, 2024

Conversation

matejmolnar
Copy link
Collaborator

This PR aims to simply the usage of DownloadAPIManager/UploadAPIManager and also unify the sample screens logic + UI.

Managers usage simplification

While I was writing a new README I realised that we are forcing the user to create unnecessary Router boiler plate in order to create a download/upload request.

Download

Hence I've created a new method on DownloadAPIManaging where you can simply pass the URL of the file you wish to download instead of Requestable. The request is then made with internal dummy DownloadRouter.

    func downloadRequest(
        _ fileURL: URL,
        resumableData: Data? = nil,
        retryConfiguration: RetryConfiguration? = .default
    ) async throws -> DownloadResult {
        try await downloadRequest(
            DownloadRouter(fileURL: fileURL),
            resumableData: resumableData,
            retryConfiguration: retryConfiguration
        )
    }

Upload

First I've created a new enum UploadType and I replaced the three different upload methods with one where you pass an uploadType parameter. Then I defined a new method where you can pass the UploadType and an upload URL. Similarly to download the request is made with internal dummy UploadRouter.

    func upload(_ type: UploadType, to uploadURL: URL) async throws -> UploadTask {
        try await upload(type, to: UploadRouter(url: uploadURL, uploadType: type))
    }

Sample logic + UI unification

  • Create UploadAPIManager shared instance.
  • Remove UploadService and use the shared manager instance instead.
  • Remove FormUploadsViewModel and move the logic to the UploadsViewModel.
  • Create new TaskProgressView with generic viewModel of TaskProgressViewModel protocol and use it in both upload and download screens.

@matejmolnar matejmolnar requested a review from a team December 21, 2023 13:24
Copy link
Collaborator

@cejanen cejanen left a comment

Choose a reason for hiding this comment

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

We're almost there. I think about few little improvements we can do here.

cejanen
cejanen previously approved these changes Jan 8, 2024
Copy link
Collaborator

@cejanen cejanen left a comment

Choose a reason for hiding this comment

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

🩴

Copy link
Collaborator

@cejanen cejanen left a comment

Choose a reason for hiding this comment

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

it took me only ages but at the end I'm happy with result
📲

Copy link
Contributor

@gajddo00 gajddo00 left a comment

Choose a reason for hiding this comment

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

🐱

@matejmolnar matejmolnar merged commit 337da1f into dev Jan 23, 2024
@matejmolnar matejmolnar deleted the feat/downloads-uploads-simplification branch February 16, 2024 13:37
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