Skip to content

Commit

Permalink
Use callback when undo/redo in Checking (#1149)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnonymousWalker committed Jun 5, 2024
1 parent 6aad6fa commit e7958ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,29 @@ class TranslationTakeApproveAction(
private val checking: CheckingStatus,
private val oldCheckingStage: TakeCheckingState
) : IUndoable {

private var undoCallback: () -> Unit = {}
private var redoCallback: () -> Unit = {}

override fun execute() {
take.checkingState.accept(TakeCheckingState(checking, take.checksum()))
}

override fun undo() {
take.checkingState.accept(oldCheckingStage)
undoCallback()
}

override fun redo() = execute()
override fun redo() {
execute()
redoCallback()
}

fun setUndoCallback(op: () -> Unit) {
undoCallback = op
}

fun setRedoCallback(op: () -> Unit) {
redoCallback = op
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ class PeerEditViewModel : ViewModel(), IWaveformViewModel {
take,
checkingStatus,
currentChecking
)
).apply {
setUndoCallback { chunkConfirmed.set(false) }
setRedoCallback { chunkConfirmed.set(true) }
}
actionHistory.execute(op)
onUndoableAction()
refreshChunkList()
Expand Down

0 comments on commit e7958ef

Please sign in to comment.