Skip to content

Commit

Permalink
Refactor: Simplify task and reminder updates, remove UiEvents
Browse files Browse the repository at this point in the history
- Replaced `taskModel.sendUiEvent(UiEvents.Update(task.id
))` with `taskModel.sendAction(Action.Insert(task.copy(id = task.id, isDone = it)))` to update task completion status.
- Replaced `reminderModel.sendUiEvent(UiEvent.Delete(observeAllReminders[index]))` with `reminderModel
.sendAction(Action.DeleteById(observeAllReminders[index].id))` for deleting reminders.
- Removed `UiEvent` and `UiEvents` import statements, as they are no longer used in this file.
- Removed unused parameters from LinkCard Composable.
These changes simplifies the logic and relies on the Action pattern.
  • Loading branch information
youndon committed Jan 12, 2025
1 parent cafcd40 commit 9280352
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ import city.zouitel.audios.ui.component.NoteAndAudioScreenModel
import city.zouitel.domain.utils.Action
import city.zouitel.links.ui.LinkCard
import city.zouitel.links.ui.LinkScreenModel
import city.zouitel.logic.events.UiEvent
import city.zouitel.logic.events.UiEvents
import city.zouitel.media.model.Media
import city.zouitel.media.ui.MediaScreen
import city.zouitel.media.ui.MediaScreenModel
Expand Down Expand Up @@ -296,12 +294,7 @@ data class WorkplaceScreen(
item {
// for refresh this screen.
observerLinks.forEach { _link ->
LinkCard(
linkScreenModel = linkModel,
uid = uid,
isSwipe = true,
link = _link
)
LinkCard(isSwipe = true, link = _link)
}
}

Expand All @@ -321,8 +314,8 @@ data class WorkplaceScreen(
modifier = Modifier
.animateContentSize()
.combinedClickable(onLongClick = {
reminderModel.sendUiEvent(
UiEvent.Delete(observeAllReminders[index])
reminderModel.sendAction(
Action.DeleteById(observeAllReminders[index].id)
)
alarmModel.cancelAlarm(observeAllReminders[index].id)
haptic.performHapticFeedback(HapticFeedbackType.LongPress)
Expand Down Expand Up @@ -391,7 +384,7 @@ data class WorkplaceScreen(
Checkbox(
checked = task.isDone,
onCheckedChange = {
taskModel.sendUiEvent(UiEvents.Update(task.id))
taskModel.sendAction(Action.Insert(task.copy(id = task.id, isDone = it)))
},
colors = CheckboxDefaults.colors(
checkedColor = Color.Gray,
Expand Down

0 comments on commit 9280352

Please sign in to comment.