|
5 | 5 | package dev.gitlive.firebase.firestore
|
6 | 6 |
|
7 | 7 | import cocoapods.FirebaseFirestore.*
|
| 8 | +import cocoapods.FirebaseFirestore.FIRDocumentChangeType.* |
8 | 9 | import dev.gitlive.firebase.*
|
9 | 10 | import kotlinx.cinterop.*
|
10 | 11 | import kotlinx.coroutines.CompletableDeferred
|
@@ -296,6 +297,12 @@ actual enum class Direction {
|
296 | 297 | DESCENDING
|
297 | 298 | }
|
298 | 299 |
|
| 300 | +actual enum class ChangeType(internal val ios: FIRDocumentChangeType) { |
| 301 | + ADDED(FIRDocumentChangeTypeAdded), |
| 302 | + MODIFIED(FIRDocumentChangeTypeModified), |
| 303 | + REMOVED(FIRDocumentChangeTypeRemoved) |
| 304 | +} |
| 305 | + |
299 | 306 | fun NSError.toException() = when(domain) {
|
300 | 307 | FIRFirestoreErrorDomain -> when(code) {
|
301 | 308 | FIRFirestoreErrorCodeOK -> FirestoreExceptionCode.OK
|
@@ -323,9 +330,22 @@ fun NSError.toException() = when(domain) {
|
323 | 330 | actual class QuerySnapshot(val ios: FIRQuerySnapshot) {
|
324 | 331 | actual val documents
|
325 | 332 | get() = ios.documents.map { DocumentSnapshot(it as FIRDocumentSnapshot) }
|
| 333 | + actual val documentChanges |
| 334 | + get() = ios.documentChanges.map { DocumentChange(it as FIRDocumentChange) } |
326 | 335 | actual val metadata: SnapshotMetadata get() = SnapshotMetadata(ios.metadata)
|
327 | 336 | }
|
328 | 337 |
|
| 338 | +actual class DocumentChange(val ios: FIRDocumentChange) { |
| 339 | + actual val document: DocumentSnapshot |
| 340 | + get() = DocumentSnapshot(ios.document) |
| 341 | + actual val newIndex: Int |
| 342 | + get() = ios.newIndex.toInt() |
| 343 | + actual val oldIndex: Int |
| 344 | + get() = ios.oldIndex.toInt() |
| 345 | + actual val type: ChangeType |
| 346 | + get() = ChangeType.values().first { it.ios == ios.type } |
| 347 | +} |
| 348 | + |
329 | 349 | @Suppress("UNCHECKED_CAST")
|
330 | 350 | actual class DocumentSnapshot(val ios: FIRDocumentSnapshot) {
|
331 | 351 |
|
|
0 commit comments