1
0
Fork 0
mirror of https://github.com/anyproto/anytype-kotlin.git synced 2025-06-08 05:47:05 +09:00

DROID-3409 Primitives | Editor, conflict layout state (#2214)

This commit is contained in:
Konstantin Ivanov 2025-03-31 20:46:18 +02:00 committed by GitHub
parent e47de0b8a0
commit 67f8686d58
Signed by: github
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 0 deletions

View file

@ -101,6 +101,8 @@ interface Editor {
val textSelection: Store<Editor.TextSelection> = Store.TextSelection()
val objectRestrictions: Store.ObjectRestrictions = Store.ObjectRestrictions()
val hasLayoutOrRelationConflict: Store<Boolean> = Store.LayoutConflict()
}
class Proxer(

View file

@ -249,6 +249,7 @@ import com.anytypeio.anytype.core_models.ext.toObject
import com.anytypeio.anytype.core_models.multiplayer.SpaceMemberPermissions
import com.anytypeio.anytype.presentation.editor.ControlPanelMachine.Event.SAM.*
import com.anytypeio.anytype.core_models.ObjectViewDetails
import com.anytypeio.anytype.domain.objects.getTypeOfObject
import com.anytypeio.anytype.presentation.editor.editor.Intent.Clipboard.Copy
import com.anytypeio.anytype.presentation.editor.editor.Intent.Clipboard.Paste
import com.anytypeio.anytype.presentation.editor.editor.ext.isAllowedToShowTypesWidget
@ -809,6 +810,7 @@ class EditorViewModel(
restrictions = orchestrator.stores.objectRestrictions.current(),
selection = currentSelection()
) { onRenderFlagFound -> flags.add(onRenderFlagFound) }
updateLayoutConflictState(currentObj, doc)
if (flags.isNotEmpty()) {
doc.fillTableOfContents()
} else {
@ -830,6 +832,31 @@ class EditorViewModel(
.launchIn(viewModelScope)
}
private suspend fun updateLayoutConflictState(
currentObject: ObjectWrapper.Basic?,
newBlocks: List<BlockView>
) {
if (currentObject == null) {
orchestrator.stores.hasLayoutOrRelationConflict.update(false)
return
}
val featuredBlock = newBlocks.firstOrNull { it is BlockView.FeaturedRelation }
val hasFeaturedPropertiesConflict =
(featuredBlock as? BlockView.FeaturedRelation)?.hasFeaturePropertiesConflict == true
val currentObjectType = storeOfObjectTypes.getTypeOfObject(currentObject)
val objectLayout = currentObject.layout
val hasObjectLayoutConflict = objectLayout != null
&& objectLayout != currentObjectType?.recommendedLayout
orchestrator.stores.hasLayoutOrRelationConflict.update(
hasObjectLayoutConflict
|| hasFeaturedPropertiesConflict
)
}
private fun refreshTableToolbar() {
val tableMode = mode
if (tableMode is EditorMode.Table) {

View file

@ -56,4 +56,5 @@ interface Store<T> {
class Details : State<ObjectViewDetails>(ObjectViewDetails.EMPTY)
class ObjectRestrictions : State<List<ObjectRestriction>>(emptyList())
class TextSelection : State<Editor.TextSelection>(Editor.TextSelection.empty())
class LayoutConflict : State<Boolean>(false)
}