Skip to content

Commit 5bb89b8

Browse files
committed
Resolve conflicts
1 parent d3b1721 commit 5bb89b8

File tree

5 files changed

+29
-15
lines changed

5 files changed

+29
-15
lines changed

firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
package dev.gitlive.firebase.database
22

3-
import dev.gitlive.firebase.firebase
3+
import dev.gitlive.firebase.database.externals.serverTimestamp
44
import kotlinx.serialization.Serializable
5-
6-
private typealias NativeServerValue = firebase.database.ServerValue
5+
import dev.gitlive.firebase.database.externals.increment as jsIncrement
76

87
/** Represents a Firebase ServerValue. */
98
@Serializable(with = ServerValueSerializer::class)
109
actual class ServerValue internal actual constructor(
1110
internal actual val nativeValue: Any
1211
){
1312
actual companion object {
14-
actual val TIMESTAMP: ServerValue get() = ServerValue(NativeServerValue.TIMESTAMP)
15-
actual fun increment(delta: Double): ServerValue = ServerValue(NativeServerValue.increment(delta))
13+
actual val TIMESTAMP: ServerValue get() = ServerValue(serverTimestamp())
14+
actual fun increment(delta: Double): ServerValue = ServerValue(jsIncrement(delta))
1615
}
1716

1817
override fun equals(other: Any?): Boolean =

firebase-database/src/jsMain/kotlin/dev/gitlive/firebase/database/externals/database.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ external fun getDatabase(
3131
url: String? = definedExternally
3232
): Database
3333

34-
external fun increment(delta: Long): Any
34+
external fun increment(delta: Double): Any
3535

3636
external fun limitToFirst(limit: Int): QueryConstraint
3737

firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package dev.gitlive.firebase.firestore
22

3-
import dev.gitlive.firebase.*
43
import kotlinx.serialization.Serializable
54

65
/** A base class that could be used to combine [Timestamp] and [Timestamp.ServerTimestamp] in the same field. */
76
@Serializable(with = BaseTimestampSerializer::class)
87
actual sealed class BaseTimestamp
98

109
/** A class representing a platform specific Firebase Timestamp. */
11-
actual typealias NativeTimestamp = firebase.firestore.Timestamp
10+
actual typealias NativeTimestamp = dev.gitlive.firebase.firestore.externals.Timestamp
1211

1312
/** A class representing a Firebase Timestamp. */
1413
@Serializable(with = TimestampSerializer::class)
@@ -33,4 +32,3 @@ actual class Timestamp internal actual constructor(
3332
@Serializable(with = ServerTimestampSerializer::class)
3433
actual object ServerTimestamp: BaseTimestamp()
3534
}
36-

firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/externals/firestore.kt

+15-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ external interface DocumentSnapshot {
179179
fun get(fieldPath: FieldPath, options: Any? = definedExternally): Any?
180180
}
181181

182-
external interface FieldValue
182+
external class FieldValue {
183+
fun isEqual(other: FieldValue): Boolean
184+
}
183185

184186
external interface Query
185187

@@ -252,3 +254,15 @@ external interface WriteBatch {
252254
vararg moreFieldsAndValues: Any?
253255
): WriteBatch
254256
}
257+
258+
external class Timestamp(seconds: Double, nanoseconds: Double) {
259+
companion object {
260+
fun now(): Timestamp
261+
}
262+
263+
val seconds: Double
264+
val nanoseconds: Double
265+
fun toMillis(): Double
266+
267+
fun isEqual(other: Timestamp): Boolean
268+
}

firebase-firestore/src/jsMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt

+8-5
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
package dev.gitlive.firebase.firestore
66

7-
import dev.gitlive.firebase.*
7+
import dev.gitlive.firebase.Firebase
88
import dev.gitlive.firebase.FirebaseApp
9+
import dev.gitlive.firebase.FirebaseException
10+
import dev.gitlive.firebase.decode
11+
import dev.gitlive.firebase.encode
912
import dev.gitlive.firebase.firestore.externals.*
1013
import kotlinx.coroutines.GlobalScope
1114
import kotlinx.coroutines.await
@@ -52,7 +55,7 @@ private fun <R> performUpdate(
5255
/** Helper method to perform an update operation. */
5356
private fun <R> performUpdate(
5457
fieldsAndValues: Array<out Pair<FieldPath, Any?>>,
55-
update: (firebase.firestore.FieldPath, Any?, Array<Any?>) -> R
58+
update: (dev.gitlive.firebase.firestore.externals.FieldPath, Any?, Array<Any?>) -> R
5659
) = performUpdate(fieldsAndValues, { it.js }, { encode(it, true) }, update)
5760

5861
actual class FirebaseFirestore(jsFirestore: Firestore) {
@@ -246,13 +249,13 @@ actual class DocumentReference(val js: JsDocumentReference) {
246249

247250
actual suspend fun update(vararg fieldsAndValues: Pair<String, Any?>) = rethrow {
248251
performUpdate(fieldsAndValues) { field, value, moreFieldsAndValues ->
249-
js.update(field, value, *moreFieldsAndValues)
252+
jsUpdate(js, field, value, *moreFieldsAndValues)
250253
}?.await()
251254
}.run { Unit }
252255

253256
actual suspend fun update(vararg fieldsAndValues: Pair<FieldPath, Any?>) = rethrow {
254257
performUpdate(fieldsAndValues) { field, value, moreFieldsAndValues ->
255-
js.update(field, value, *moreFieldsAndValues)
258+
jsUpdate(js, field, value, *moreFieldsAndValues)
256259
}?.await()
257260
}.run { Unit }
258261

@@ -444,7 +447,7 @@ actual class FieldPath private constructor(val js: JsFieldPath) {
444447
}
445448

446449
/** Represents a platform specific Firebase FieldValue. */
447-
private typealias NativeFieldValue = firebase.firestore.FieldValue
450+
private typealias NativeFieldValue = dev.gitlive.firebase.firestore.externals.FieldValue
448451

449452
/** Represents a Firebase FieldValue. */
450453
@Serializable(with = FieldValueSerializer::class)

0 commit comments

Comments
 (0)