#74 added single getSubject so feed kan fetch only one subject
This commit is contained in:
		
							parent
							
								
									bee7101bef
								
							
						
					
					
						commit
						dab4506a34
					
				
					 1 changed files with 7 additions and 0 deletions
				
			
		|  | @ -1,13 +1,16 @@ | |||
| package be.ugent.sel.studeez.domain.implementation | ||||
| 
 | ||||
| import be.ugent.sel.studeez.data.local.models.task.Subject | ||||
| import be.ugent.sel.studeez.data.local.models.task.Task | ||||
| import be.ugent.sel.studeez.domain.AccountDAO | ||||
| import be.ugent.sel.studeez.domain.SubjectDAO | ||||
| import com.google.firebase.firestore.CollectionReference | ||||
| import com.google.firebase.firestore.FirebaseFirestore | ||||
| import com.google.firebase.firestore.ktx.snapshots | ||||
| import com.google.firebase.firestore.ktx.toObject | ||||
| import kotlinx.coroutines.flow.Flow | ||||
| import kotlinx.coroutines.flow.map | ||||
| import kotlinx.coroutines.tasks.await | ||||
| import javax.inject.Inject | ||||
| 
 | ||||
| class FireBaseSubjectDAO @Inject constructor( | ||||
|  | @ -20,6 +23,10 @@ class FireBaseSubjectDAO @Inject constructor( | |||
|             .map { it.toObjects(Subject::class.java) } | ||||
|     } | ||||
| 
 | ||||
|     override suspend fun getSubject(subjectId: String): Subject? { | ||||
|         return currentUserSubjectsCollection().document(subjectId).get().await().toObject() | ||||
|     } | ||||
| 
 | ||||
|     override fun saveSubject(newSubject: Subject) { | ||||
|         currentUserSubjectsCollection().add(newSubject) | ||||
|     } | ||||
|  |  | |||
		Reference in a new issue
	
	 lbarraga
						lbarraga