From 1f16c75121ee324595ca20620b5ec124e43c1b5e Mon Sep 17 00:00:00 2001 From: João Ferreiro Date: Tue, 29 Nov 2022 17:46:55 +0000 Subject: use runInAction in getPhotos model --- src/state/models/user-local-photos.ts | 8 +++++--- src/view/com/composer/PhotoCarouselPicker.tsx | 13 ++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/state/models/user-local-photos.ts b/src/state/models/user-local-photos.ts index 4e01f1d94..12b95e376 100644 --- a/src/state/models/user-local-photos.ts +++ b/src/state/models/user-local-photos.ts @@ -1,5 +1,5 @@ import {PhotoIdentifier} from './../../../node_modules/@react-native-camera-roll/camera-roll/src/CameraRoll' -import {makeAutoObservable} from 'mobx' +import {makeAutoObservable, runInAction} from 'mobx' import {CameraRoll} from '@react-native-camera-roll/camera-roll' import {RootStoreModel} from './root-store' @@ -18,8 +18,10 @@ export class UserLocalPhotosModel { } private async _getPhotos() { - CameraRoll.getPhotos({first: 20}).then(r => { - this.photos = r.edges + runInAction(() => { + CameraRoll.getPhotos({first: 20}).then(r => { + this.photos = r.edges + }) }) } } diff --git a/src/view/com/composer/PhotoCarouselPicker.tsx b/src/view/com/composer/PhotoCarouselPicker.tsx index 6a2b9712e..e6b308dcb 100644 --- a/src/view/com/composer/PhotoCarouselPicker.tsx +++ b/src/view/com/composer/PhotoCarouselPicker.tsx @@ -2,14 +2,9 @@ import React from 'react' import {Image, StyleSheet, TouchableOpacity, ScrollView} from 'react-native' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {colors} from '../../lib/styles' -import { - openPicker, - openCamera, - ImageOrVideo, -} from 'react-native-image-crop-picker' -import {observer} from 'mobx-react-lite' +import {openPicker, openCamera} from 'react-native-image-crop-picker' -export const PhotoCarouselPicker = observer(function PhotoCarouselPicker({ +export const PhotoCarouselPicker = ({ selectedPhotos, setSelectedPhotos, localPhotos, @@ -17,7 +12,7 @@ export const PhotoCarouselPicker = observer(function PhotoCarouselPicker({ selectedPhotos: string[] setSelectedPhotos: React.Dispatch> localPhotos: any -}) { +}) => { return ( ) -}) +} const styles = StyleSheet.create({ photosContainer: { -- cgit 1.4.1