File tree Expand file tree Collapse file tree
database/src/main/java/dev/dineshktech/app/starter/database/model
data/src/main/java/dev/dineshktech/app/starter/data
domain/src/main/java/dev/dineshktech/app/starter/core/domain Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,4 +11,4 @@ fun Note.asExternalModel() = NotesyEntity(
1111 color = color,
1212 isFavourite = isFavourite,
1313)
14- class InvalidNoteException (message : String ) : Exception(message)
14+ class InvalidNoteException (message : String ) : Exception(message)
Original file line number Diff line number Diff line change @@ -19,14 +19,14 @@ class OfflineFirstNotesRepository @Inject constructor(
1919 }
2020
2121 override suspend fun getNote (id : Int ): Flow <Note > {
22- return notesyDao.getNote(id).map { it.asExternalModel() }
22+ return notesyDao.getNote(id).map { it.asExternalModel() }
2323 }
2424
2525 override suspend fun deleteNote (note : Note ) {
2626 notesyDao.deleteNotes(arrayListOf (note.id))
2727 }
2828
2929 override suspend fun upsertNote (note : Note ) {
30- notesyDao.upsertNotes(arrayListOf (note.asExternalModel()))
30+ notesyDao.upsertNotes(arrayListOf (note.asExternalModel()))
3131 }
3232}
Original file line number Diff line number Diff line change @@ -25,4 +25,3 @@ fun NotesyEntity.asExternalModel() = Note(
2525 color = color,
2626 isFavourite = isFavourite,
2727)
28-
Original file line number Diff line number Diff line change @@ -13,18 +13,18 @@ class GetNotesUseCase @Inject constructor(
1313) {
1414 suspend operator fun invoke (notesOrder : NotesOrder = NotesOrder .Date (OrderType .Ascending )): Flow <List <Note >> {
1515 return notesRepository.getNotesStream().map { notes ->
16- when (notesOrder.orderType){
16+ when (notesOrder.orderType) {
1717 is OrderType .Ascending -> {
18- when (notesOrder){
18+ when (notesOrder) {
1919 is NotesOrder .Title -> notes.sortedBy { it.title.lowercase() }
20- is NotesOrder .Date -> notes.sortedBy { it.timestamp}
20+ is NotesOrder .Date -> notes.sortedBy { it.timestamp }
2121 is NotesOrder .Color -> notes.sortedBy { it.color }
2222 }
2323 }
2424 is OrderType .Descending -> {
25- when (notesOrder){
25+ when (notesOrder) {
2626 is NotesOrder .Title -> notes.sortedByDescending { it.title.lowercase() }
27- is NotesOrder .Date -> notes.sortedByDescending { it.timestamp}
27+ is NotesOrder .Date -> notes.sortedByDescending { it.timestamp }
2828 is NotesOrder .Color -> notes.sortedByDescending { it.color }
2929 }
3030 }
Original file line number Diff line number Diff line change @@ -9,11 +9,11 @@ class UpsertNotesUseCase @Inject constructor(
99 private val notesRepository : NotesRepository ,
1010) {
1111 suspend operator fun invoke (note : Note ) {
12- if (note.title.isNotBlank() || note.content.isNotBlank()) {
12+ if (note.title.isNotBlank() || note.content.isNotBlank()) {
1313 notesRepository.upsertNote(note)
14- } else if (note.title.isBlank()) {
14+ } else if (note.title.isBlank()) {
1515 throw InvalidNoteException (" title can't be empty" )
16- } else if (note.content.isBlank()) {
16+ } else if (note.content.isBlank()) {
1717 throw InvalidNoteException (" content can't be empty" )
1818 }
1919 }
Original file line number Diff line number Diff line change @@ -8,8 +8,8 @@ sealed class NotesOrder(val orderType: OrderType) {
88 fun copy (orderType : OrderType ): NotesOrder {
99 return when (this ) {
1010 is Title -> Title (orderType)
11- is Date -> Date (orderType)
11+ is Date -> Date (orderType)
1212 is Color -> Color (orderType)
1313 }
1414 }
15- }
15+ }
Original file line number Diff line number Diff line change @@ -3,4 +3,4 @@ package dev.dineshktech.app.starter.core.domain.utils
33sealed class OrderType {
44 object Ascending : OrderType()
55 object Descending : OrderType()
6- }
6+ }
You can’t perform that action at this time.
0 commit comments