Skip to content

[expo-media-library][iOS] add support for filtering assets by media subtype #36756

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 8 commits into from
Jul 11, 2025

Conversation

clarkg
Copy link
Contributor

@clarkg clarkg commented May 8, 2025

Why

this would be very convenient to be able to filter for screenshots, for example, without needing to overfetch

How

extended AssetOptions with mediaSubtypes

main logic implemented in getAssetsWithAfter in MediaLibraryUtilities.swift

Test Plan

test-suite

Checklist

Copy link
Contributor

github-actions bot commented May 8, 2025

Subscribed to pull request

File Patterns Mentions
packages/expo-media-library/** @behenate, @alanjhughes

Generated by CodeMention

@expo-bot expo-bot added the bot: suggestions ExpoBot has some suggestions label May 8, 2025
@clarkg clarkg force-pushed the filter-subtype branch from 0a93310 to 05a721d Compare May 8, 2025 21:15
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels May 8, 2025
@clarkg clarkg force-pushed the filter-subtype branch from dd9faa8 to b0f5a24 Compare May 8, 2025 23:30
@vonovak vonovak self-assigned this May 23, 2025
@clarkg
Copy link
Contributor Author

clarkg commented May 24, 2025

@vonovak thanks for self-assigning this. idk how to re-run the Test Suite / ios-test since the failure just looks like a timeout

@vonovak
Copy link
Contributor

vonovak commented May 26, 2025

@vonovak thanks for self-assigning this. idk how to re-run the Test Suite / ios-test since the failure just looks like a timeout

can you please rebase this on latest main?

Copy link
Contributor

@vonovak vonovak left a comment

Choose a reason for hiding this comment

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

Thank you for the PR!

I believe mediaSubtypes need to receive the arrayize treatment like here

mediaType: arrayize(mediaType || [MediaType.photo]),

Also if you could add an example of this in one of the screens here that'd be great - it'll speed up the review process, though not strictly necessary.
Also pls rebase on latest main.

Thank you!

.yarnrc.yml Outdated
@@ -0,0 +1 @@
nodeLinker: node-modules
Copy link
Contributor

Choose a reason for hiding this comment

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

let's remove this file pls

@vonovak
Copy link
Contributor

vonovak commented Jun 19, 2025

@clarkg hello, can you please resolve the review comments?
Thank you!

@expo-bot expo-bot added bot: suggestions ExpoBot has some suggestions and removed bot: passed checks ExpoBot has nothing to complain about labels Jul 9, 2025
@expo-bot expo-bot added bot: passed checks ExpoBot has nothing to complain about and removed bot: suggestions ExpoBot has some suggestions labels Jul 9, 2025
Copy link
Contributor

@vonovak vonovak left a comment

Choose a reason for hiding this comment

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

Addressed my own review, did some small refactors

@@ -2,38 +2,6 @@ import ExpoModulesCore
import Photos
import CoreServices

func stringify(mediaType: PHAssetMediaType) -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

moved this to MediaType.init(fromPHAssetMediaType mediaType: PHAssetMediaType) to prevent the two from going out of sync

}

func stringifyMedia(mediaSubtypes: PHAssetMediaSubtype) -> [String] {
let subtypesDict: [String: PHAssetMediaSubtype] = [
Copy link
Contributor

Choose a reason for hiding this comment

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

moved to MediaSubtype.stringify

@vonovak vonovak requested a review from alanjhughes July 9, 2025 15:08
@clarkg
Copy link
Contributor Author

clarkg commented Jul 9, 2025

oh wow thank you @vonovak !

@vonovak vonovak merged commit bcdf1e2 into expo:main Jul 11, 2025
19 of 20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot: passed checks ExpoBot has nothing to complain about
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants