about summary refs log tree commit diff
path: root/src/state/models
diff options
context:
space:
mode:
authorJoão Ferreiro <joaoferreiro5@gmail.com>2022-12-02 16:41:01 +0000
committerGitHub <noreply@github.com>2022-12-02 10:41:01 -0600
commit67c4dcff3731444c6e6eadcbed1d55bd503bda4a (patch)
treefc15ad58ca5694135851e189faf8a389ff5c933d /src/state/models
parent7ae1bac6208c6c00363aae344c76261a28433614 (diff)
downloadvoidsky-67c4dcff3731444c6e6eadcbed1d55bd503bda4a.tar.zst
Upload image in composer (#27)
* upload images in composer v1

* fix android compile

* reafctor image carousel into new component;
fix photo overlapping text in composer

* revert android changes

* further refactoring code into different components

* move show carousel out of the component

* fixing add photo using camera

* fix typescript issue; force mediatype photo

* change post test with photo attached;
remove auto linking settings

* use runInAction in getPhotos model

* react-hooks/exhaustive-deps fixes

* crop every photo;
make use of useCallback

* moving placeholder condition

* Cleanup

Co-authored-by: Paul Frazee <pfrazee@gmail.com>
Diffstat (limited to 'src/state/models')
-rw-r--r--src/state/models/user-local-photos.ts27
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
+      })
+    })
+  }
+}