wordpress-mobile / wordpress-mobile/GutenbergKit

Split the media-handler files into one type per file

Open
#622 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29
Forks
6
Avg merge
1d 9h
Merged PRs (30d)
41

Description

Follow-up from #621. The media files each hold several types, so the "server" files are doing far too much:

  • ios/.../Media/MediaUploadServer.swift — ~795 lines: the server plus the ~275-line InternalMediaClient, UploadError, and UploadContext.
  • android/.../gutenberg/MediaUploadServer.kt — ~758 lines: the response model, both protocols, both value types, the server, the exception, and the client.

Proposed split

One concern per file, kept in the same module/package — so no import-path or public-API change, purely organization:

File Holds
MediaProcessor.{swift,kt} MediaProcessor (+ the iOS default-impl extension) & its result type ProcessedProxyFile
MediaUploader.{swift,kt} MediaUploader & its input type MediaUpload
MediaUploadResponse.{swift,kt} MediaUploadResponse (the shared internal relay model)
InternalMediaClient.{swift,kt} InternalMediaClient (the concrete configured-site REST client)
MediaUploadServer.{swift,kt} the server + its privates (UploadContext; UploadError / MediaUploadException)

iOS's MediaHandlers.swift dissolves into the first three.

Grouping rationale: each value type sits with the protocol it serves (ProcessedProxyFile → processor, MediaUpload → uploader); MediaUploadResponse gets a neutral home since the client and the server both use it; server-privates stay with the server.

Notes

  • Mechanical and low-risk — no logic changes, stays within the existing module/package, so hosts see no API change. Builds + the existing media test suites are the check.
  • Keep the media types in the org.wordpress.gutenberg package on Android; a media subpackage would be a public-API break for hosts.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ios/.../Media/MediaUploadServer.swift, ios/.../Media/MediaHandlers.swift, and android/.../gutenberg/MediaUploadServer.kt to identify each listed type and its module or package. Review the existing media test suites before moving declarations. Done means one concern per proposed file, Android types remain in org.wordpress.gutenberg, and builds and media tests still pass without API or logic changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin, swift
Domain
mobile-dev
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.