about summary refs log tree commit diff
path: root/src/state/models/user-local-photos.ts
blob: b14e8a6a4dc25015440b6c27a36bd8fbc4a72e70 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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 type {PhotoIdentifier} from './../../../node_modules/@react-native-camera-roll/camera-roll/src/CameraRoll'

export class UserLocalPhotosModel {
  // state
  photos: PhotoIdentifier[] = []

  constructor(public rootStore: RootStoreModel) {
    makeAutoObservable(this, {
      rootStore: false,
    })
  }

  async setup() {
    const r = await CameraRoll.getPhotos({first: 20})
    runInAction(() => {
      this.photos = r.edges
    })
  }
}