@@ -10,16 +10,16 @@ import javax.inject.*
1010
1111@Singleton
1212class ListingRepo @Inject constructor(context : Context ) {
13- private var listingDao : ListingDao ?
13+ private var listingsDao : ListingDao ?
1414
1515 init {
1616 val db = AppDatabase .getDatabase(context)
17- listingDao = db?.listingDao ()
17+ listingsDao = db?.listingsDao ()
1818 }
1919
2020 suspend fun fetchListings (parent : Int ): List <ListingUi > {
2121 return withContext(Dispatchers .IO ) {
22- val allListings = listingDao ?.getAll(parent) ? : emptyList()
22+ val allListings = listingsDao ?.getAll(parent) ? : emptyList()
2323
2424 allListings.map { listing ->
2525 ListingUi (
@@ -29,7 +29,7 @@ class ListingRepo @Inject constructor(context: Context) {
2929 song = listing.song,
3030 created = listing.created,
3131 modified = listing.modified,
32- songCount = listingDao ?.countSongs(listing.id) ? : 0 ,
32+ songCount = listingsDao ?.countSongs(listing.id) ? : 0 ,
3333 updatedAgo = listing.modified.toLongOrNull()?.toTimeAgo() ? : " "
3434 )
3535 }
@@ -46,21 +46,21 @@ class ListingRepo @Inject constructor(context: Context) {
4646 created = currentTime,
4747 modified = currentTime
4848 )
49- listingDao ?.insert(newListing)
49+ listingsDao ?.insert(newListing)
5050 }
5151 }
5252
5353 suspend fun saveListItem (parent : ListingUi , song : Int ) {
5454 withContext(Dispatchers .IO ) {
5555 val currentTime = System .currentTimeMillis().toString()
56- listingDao ?.insert(Listing (
56+ listingsDao ?.insert(Listing (
5757 parent = parent.id,
5858 title = " " ,
5959 song = song,
6060 created = currentTime,
6161 modified = currentTime
6262 ))
63- listingDao ?.update(Listing (
63+ listingsDao ?.update(Listing (
6464 parent = parent.id,
6565 title = parent.title,
6666 song = song,
@@ -73,7 +73,7 @@ class ListingRepo @Inject constructor(context: Context) {
7373 suspend fun updateListing (listing : ListingUi ) {
7474 val currentTime = System .currentTimeMillis().toString()
7575 withContext(Dispatchers .IO ) {
76- listingDao ?.update(Listing (
76+ listingsDao ?.update(Listing (
7777 parent = listing.id,
7878 title = listing.title,
7979 song = listing.song,
@@ -85,13 +85,13 @@ class ListingRepo @Inject constructor(context: Context) {
8585
8686 suspend fun deleteById (listId : Int ) {
8787 withContext(Dispatchers .IO ) {
88- listingDao ?.deleteById(listId)
88+ listingsDao ?.deleteById(listId)
8989 }
9090 }
9191
9292 suspend fun deleteAllListings () {
9393 withContext(Dispatchers .IO ) {
94- listingDao ?.deleteAll()
94+ listingsDao ?.deleteAll()
9595 }
9696 }
9797
0 commit comments