1
0
Fork 0
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:
Evgenii Kozlov 2020-11-19 15:26:08 +02:00 committed by GitHub
parent a4ddf06439
commit 5dd6f9810f
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View file

@ -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 ⚙

View file

@ -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.")