mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
Do not crash if document's title is broken after paste (#1108)
This commit is contained in:
parent
a4ddf06439
commit
5dd6f9810f
2 changed files with 12 additions and 7 deletions
|
@ -12,6 +12,7 @@
|
|||
|
||||
* Should save the latest text input if you close the page quickly (#1067)
|
||||
* Keyboard won't show up in code snippet on Android 7 (#1024)
|
||||
* Do not crash if document's title is broken after paste (#1108)
|
||||
|
||||
### Middleware ⚙
|
||||
|
||||
|
|
|
@ -544,14 +544,18 @@ class PageViewModel(
|
|||
val first = event.blocks.first { it.id == root.children.first() }
|
||||
val content = first.content
|
||||
if (content is Content.Layout && content.type == Content.Layout.Type.HEADER) {
|
||||
val title = event.blocks.title()
|
||||
val focus = Editor.Focus(id = title.id, cursor = Editor.Cursor.End)
|
||||
viewModelScope.launch { orchestrator.stores.focus.update(focus) }
|
||||
controlPanelInteractor.onEvent(
|
||||
ControlPanelMachine.Event.OnFocusChanged(
|
||||
id = title.id, style = Content.Text.Style.TITLE
|
||||
try {
|
||||
val title = event.blocks.title()
|
||||
val focus = Editor.Focus(id = title.id, cursor = Editor.Cursor.End)
|
||||
viewModelScope.launch { orchestrator.stores.focus.update(focus) }
|
||||
controlPanelInteractor.onEvent(
|
||||
ControlPanelMachine.Event.OnFocusChanged(
|
||||
id = title.id, style = Content.Text.Style.TITLE
|
||||
)
|
||||
)
|
||||
)
|
||||
} catch (e: Throwable) {
|
||||
Timber.e(e, "Error while initial focusing")
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> Timber.d("Skipping initial focusing, document is not empty.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue