Skip to content

Conversation

tsapeta
Copy link
Contributor

@tsapeta tsapeta commented Aug 2, 2019

Why

There are some use cases where we want to pick media assets from some specific period of time, like during a visit in a food place. That use case is also used in Gyroscope app where I wanted to make it work more smoothly and get rid of filtering all the assets in JS.

How

Added createdAfter and createdBefore options to MediaLibrary.getAssetsAsync and also added requestPermissionsAsync and getPermissionsAsync functions which would also be a part of #5061 but I decided to include them earlier so I don't have to migrate in the future releases 😅

Test Plan

Added tests to test-suite + I tested it in Gyroscope app

@tsapeta tsapeta marked this pull request as ready for review August 5, 2019 08:42
@tsapeta tsapeta requested a review from bbarthec as a code owner August 5, 2019 08:42
@tsapeta tsapeta requested a review from sjchmiela August 5, 2019 09:01
@@ -93,6 +95,11 @@ export type PagedInfo<T> = {
totalCount: number;
};

export type PermissionsResult = {
status: 'granted' | 'denied' | 'undetermined';
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe extract that to some Enum and export as well. That would allow users to use library provided const and not if (someResult === 'granted)` 🤔 ❓

Copy link
Contributor

@sjchmiela sjchmiela left a comment

Choose a reason for hiding this comment

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

Thanks for implementing this!

@@ -76,6 +77,26 @@ - (NSDictionary *)constantsToExport
return @[EXMediaLibraryDidChangeEvent];
}

UM_EXPORT_METHOD_AS(requestPermissionsAsync,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this some forward-looking solution where in the future we will deprecate asking for permissions via expo-permissions? Is making this change in a random module fit in a bigger scope? (i. e. wouldn't we like to copy-and-deprecate all the methods in one PR rather than in multiple random PRs)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Moreover, maybe the redirection could happen on JS level?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this some forward-looking solution where in the future we will deprecate asking for permissions via expo-permissions?

Yes, this is also already implemented in other modules like Location and Calendar which provide its own methods requesting for permissions. This is in the scope of #5061 but I think it doesn't bother to implement it earlier. I already discussed it with @lukmccall who is working on the new permissions. The code of these methods will probably be changed by his PR anyway, but the signature shouldn't change.

Moreover, maybe the redirection could happen on JS level?

I don't really want to add expo-permissions as a dependency of expo-media-library, even though expo-permissions are installed by react-native-unimodules, I guess we planned to not have such deps between unimodules.

@tsapeta tsapeta merged commit 8e06e51 into master Aug 5, 2019
@tsapeta tsapeta deleted the @tsapeta/media-library-time-range branch August 5, 2019 13:30
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