fix: inject FirebaseFirestore via constructor instead of getInstance()

This commit is contained in:
null 2026-06-17 20:53:42 -05:00
parent e5c734d3b2
commit d6f5eb6b0f
8 changed files with 8 additions and 24 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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? =