diff options
Diffstat (limited to 'src/state')
-rw-r--r-- | src/state/models/user-local-photos.ts | 25 |
1 files changed, 25 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..4e01f1d94 --- /dev/null +++ b/src/state/models/user-local-photos.ts @@ -0,0 +1,25 @@ +import {PhotoIdentifier} from './../../../node_modules/@react-native-camera-roll/camera-roll/src/CameraRoll' +import {makeAutoObservable} 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 => { + this.photos = r.edges + }) + } +} |