diff options
Diffstat (limited to 'src/state/models/user-local-photos.ts')
-rw-r--r-- | src/state/models/user-local-photos.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/state/models/user-local-photos.ts b/src/state/models/user-local-photos.ts new file mode 100644 index 000000000..9a1455039 --- /dev/null +++ b/src/state/models/user-local-photos.ts @@ -0,0 +1,27 @@ +import {PhotoIdentifier} from './../../../node_modules/@react-native-camera-roll/camera-roll/src/CameraRoll' +import {makeAutoObservable, runInAction} from 'mobx' +import {CameraRoll} from '@react-native-camera-roll/camera-roll' +import {RootStoreModel} from './root-store' + +export class UserLocalPhotosModel { + // state + photos: PhotoIdentifier[] = [] + + constructor(public rootStore: RootStoreModel) { + makeAutoObservable(this, { + rootStore: false, + }) + } + + async setup() { + await this._getPhotos() + } + + private async _getPhotos() { + CameraRoll.getPhotos({first: 20}).then(r => { + runInAction(() => { + this.photos = r.edges + }) + }) + } +} |