fix: inject FirebaseFirestore via constructor instead of getInstance()
This commit is contained in:
parent
e5c734d3b2
commit
d6f5eb6b0f
|
|
@ -22,9 +22,7 @@ import kotlin.coroutines.resumeWithException
|
|||
* Categories: Adventure, Travel, Food, Learning, Romance, Intimacy, Seasonal.
|
||||
*/
|
||||
@Singleton
|
||||
class FirestoreBucketListDataSource @Inject constructor() {
|
||||
|
||||
private val db = FirebaseFirestore.getInstance()
|
||||
class FirestoreBucketListDataSource @Inject constructor(private val db: FirebaseFirestore) {
|
||||
private fun itemsRef(coupleId: String) =
|
||||
db.collection(FirestoreCollections.COUPLES).document(coupleId)
|
||||
.collection(FirestoreCollections.Couples.BUCKET_LIST)
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ import kotlin.coroutines.resume
|
|||
import kotlin.coroutines.resumeWithException
|
||||
|
||||
@Singleton
|
||||
class FirestoreCoupleDataSource @Inject constructor() {
|
||||
|
||||
private val db = FirebaseFirestore.getInstance()
|
||||
class FirestoreCoupleDataSource @Inject constructor(private val db: FirebaseFirestore) {
|
||||
private fun coupleRef(coupleId: String) = db.collection(FirestoreCollections.COUPLES).document(coupleId)
|
||||
private fun userRef(uid: String) = db.collection(FirestoreCollections.USERS).document(uid)
|
||||
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ import kotlin.coroutines.resumeWithException
|
|||
* still exposes a create helper for the function trigger path.
|
||||
*/
|
||||
@Singleton
|
||||
class FirestoreDateMatchDataSource @Inject constructor() {
|
||||
|
||||
private val db = FirebaseFirestore.getInstance()
|
||||
class FirestoreDateMatchDataSource @Inject constructor(private val db: FirebaseFirestore) {
|
||||
private fun matchesRef(coupleId: String) =
|
||||
db.collection(FirestoreCollections.COUPLES).document(coupleId)
|
||||
.collection(FirestoreCollections.Couples.DATE_MATCHES)
|
||||
|
|
|
|||
|
|
@ -25,9 +25,7 @@ import kotlin.coroutines.resumeWithException
|
|||
* Local-first: Preferences stored in Room. Plans synced to Firestore when explicitly shared/scheduled.
|
||||
*/
|
||||
@Singleton
|
||||
class FirestoreDatePlanDataSource @Inject constructor() {
|
||||
|
||||
private val db = FirebaseFirestore.getInstance()
|
||||
class FirestoreDatePlanDataSource @Inject constructor(private val db: FirebaseFirestore) {
|
||||
private fun preferencesRef(coupleId: String) =
|
||||
db.collection(FirestoreCollections.COUPLES).document(coupleId)
|
||||
.collection(FirestoreCollections.Couples.DATE_PLAN_PREFERENCES)
|
||||
|
|
|
|||
|
|
@ -33,9 +33,7 @@ import kotlin.coroutines.resumeWithException
|
|||
* only write their own action entry.
|
||||
*/
|
||||
@Singleton
|
||||
class FirestoreDateSwipeDataSource @Inject constructor() {
|
||||
|
||||
private val db = FirebaseFirestore.getInstance()
|
||||
class FirestoreDateSwipeDataSource @Inject constructor(private val db: FirebaseFirestore) {
|
||||
private fun swipesRef(coupleId: String) =
|
||||
db.collection(FirestoreCollections.COUPLES).document(coupleId)
|
||||
.collection(FirestoreCollections.Couples.DATE_SWIPES)
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@ import kotlin.coroutines.resumeWithException
|
|||
import kotlin.random.Random
|
||||
|
||||
@Singleton
|
||||
class FirestoreInviteDataSource @Inject constructor() {
|
||||
|
||||
private val db = FirebaseFirestore.getInstance()
|
||||
class FirestoreInviteDataSource @Inject constructor(private val db: FirebaseFirestore) {
|
||||
private fun inviteRef(code: String) = db.collection(FirestoreCollections.INVITES).document(code)
|
||||
|
||||
fun generateCode(): String = (1..6)
|
||||
|
|
|
|||
|
|
@ -19,9 +19,7 @@ import kotlin.coroutines.resume
|
|||
import kotlin.coroutines.resumeWithException
|
||||
|
||||
@Singleton
|
||||
class FirestoreQuestionThreadDataSource @Inject constructor() {
|
||||
|
||||
private val db = FirebaseFirestore.getInstance()
|
||||
class FirestoreQuestionThreadDataSource @Inject constructor(private val db: FirebaseFirestore) {
|
||||
|
||||
private fun threadsRef(coupleId: String) =
|
||||
db.collection(FirestoreCollections.COUPLES).document(coupleId)
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@ import kotlin.coroutines.resume
|
|||
import kotlin.coroutines.resumeWithException
|
||||
|
||||
@Singleton
|
||||
class FirestoreUserDataSource @Inject constructor() {
|
||||
|
||||
private val db = FirebaseFirestore.getInstance()
|
||||
class FirestoreUserDataSource @Inject constructor(private val db: FirebaseFirestore) {
|
||||
private fun userRef(uid: String) = db.collection(FirestoreCollections.USERS).document(uid)
|
||||
|
||||
suspend fun getUser(uid: String): User? =
|
||||
|
|
|
|||
Loading…
Reference in New Issue