Skip to content

Commit

Permalink
choreEventRepositoryFirestore): Adapt the EventRepositoryFirestore to…
Browse files Browse the repository at this point in the history
… use global path variables and expose its hydration function
  • Loading branch information
oskar-codes committed Oct 10, 2024
1 parent 3dcab09 commit 2eddd76
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.android.unio.model.event

import android.util.Log
import com.android.unio.model.firestore.FirestorePaths.EVENT_PATH
import com.google.firebase.Timestamp
import com.google.firebase.firestore.DocumentSnapshot
import com.google.firebase.firestore.FirebaseFirestore
Expand Down Expand Up @@ -77,16 +78,13 @@ class EventRepositoryFirestore(private val db: FirebaseFirestore) : EventReposit
}
}

private fun hydrate(doc: DocumentSnapshot): Event? {

val event = doc.toObject(Event::class.java)
if (event == null) {
Log.e("EventRepositoryFirestore", "Error while converting db document to Event object")
}
return event
}

companion object {
private const val EVENT_PATH = "events"
fun hydrate(doc: DocumentSnapshot): Event? {
val event = doc.toObject(Event::class.java)
if (event == null) {
Log.e("EventRepositoryFirestore", "Error while converting db document to Event object")
}
return event
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ package com.android.unio.model.firestore
object FirestorePaths {
const val ASSOCIATION_PATH = "associations"
const val USER_PATH = "users"
const val EVENT_PATH = "events"
}

0 comments on commit 2eddd76

Please sign in to comment.