Skip to content

Commit

Permalink
Handle edge case and add documentation with plugin (#1169)
Browse files Browse the repository at this point in the history
* handle return from plugin in Blind Draft

* documentation
  • Loading branch information
AnonymousWalker authored Jul 26, 2024
1 parent 0b68cde commit c8877dd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class GoToPreviousChapterEvent: FXEvent()
class OpenInPluginEvent: FXEvent()

/**
* Use this event to avoid unwanted refresh of steps or chunk list
* when returning from an external plugin.
* Use this event to avoid unwanted auto-navigation or state refresh
* when returning from an external plugin. Only fire this event inside
* onDock() of main view in Translation.
*/
class ReturnFromPluginEvent: FXEvent()
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class ChunkingTranslationPage : View() {
super.onDock()
when (viewModel.pluginOpenedProperty.value) {
true -> {
// returning from plugin
// returning from plugin, notify child view without triggering onDock()
FX.eventbus.fire(ReturnFromPluginEvent())
}
false -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import org.wycliffeassociates.otter.jvm.controls.styles.tryImportStylesheet
import org.wycliffeassociates.otter.jvm.workbookapp.ui.components.ChunkTakeCard
import org.wycliffeassociates.otter.jvm.controls.event.ChunkTakeEvent
import org.wycliffeassociates.otter.jvm.controls.event.RedoChunkingPageEvent
import org.wycliffeassociates.otter.jvm.controls.event.ReturnFromPluginEvent
import org.wycliffeassociates.otter.jvm.controls.event.TakeAction
import org.wycliffeassociates.otter.jvm.controls.event.UndoChunkingPageEvent
import org.wycliffeassociates.otter.jvm.utils.ListenerDisposer
Expand Down Expand Up @@ -269,6 +270,10 @@ class BlindDraft : View() {
workspace.dock(pluginOpenedPage)
}
}.let { eventSubscriptions.add(it) }

subscribe<ReturnFromPluginEvent> {
viewModel.pluginOpenedProperty.set(false)
}.let { eventSubscriptions.add(it) }
}

private fun unsubscribeEvents() {
Expand Down

0 comments on commit c8877dd

Please sign in to comment.