diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/Block.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/Block.kt index 21ed58e0ab..52bde961d7 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/Block.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/Block.kt @@ -50,7 +50,6 @@ data class Block( } val id: Id? by default - val isDraft: Boolean? by default val snippet: String? by default val layout: Double? diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectWrapper.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectWrapper.kt index 90e9695010..6b319e5de5 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectWrapper.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/ObjectWrapper.kt @@ -83,8 +83,6 @@ sealed class ObjectWrapper { val description: String? by default - val isDraft: Boolean? by default - val url: String? by default val featuredRelations: List? by default diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/Relations.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/Relations.kt index b97d1445b3..75171f0a5a 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/Relations.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/Relations.kt @@ -26,13 +26,9 @@ object Relations { const val TARGET_OBJECT_TYPE = "targetObjectType" const val DONE = "done" const val FEATURED_RELATIONS = "featuredRelations" - const val FILE_EXT = "fileExt" - const val FILE_MIME_TYPE = "fileMimeType" const val SNIPPET = "snippet" - const val IS_DRAFT = "isDraft" const val WORKSPACE_ID = "workspaceId" const val SET_OF = "setOf" - const val IS_HIGHLIGHTED = "isHighlighted" const val URL = "url" const val SOURCE = "source" const val SMARTBLOCKTYPES = "smartblockTypes" diff --git a/domain/src/main/java/com/anytypeio/anytype/domain/page/CreateObject.kt b/domain/src/main/java/com/anytypeio/anytype/domain/page/CreateObject.kt index 512c813fc3..80fe5615e9 100644 --- a/domain/src/main/java/com/anytypeio/anytype/domain/page/CreateObject.kt +++ b/domain/src/main/java/com/anytypeio/anytype/domain/page/CreateObject.kt @@ -52,7 +52,9 @@ class CreateObject( return Result( objectId = result.id, - event = result.event + event = result.event, + appliedTemplate = template, + type = type ) } @@ -62,6 +64,8 @@ class CreateObject( data class Result( val objectId: Id, - val event: Payload + val event: Payload, + val appliedTemplate: String? = null, + val type: String? = null ) } \ No newline at end of file diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/DocumentExternalEventReducer.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/DocumentExternalEventReducer.kt index e2c104e4a6..7f338a1e4a 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/DocumentExternalEventReducer.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/DocumentExternalEventReducer.kt @@ -168,8 +168,7 @@ object Flags { val skipRefreshKeys = listOf( Relations.NAME, Relations.LAST_MODIFIED_DATE, - Relations.SNIPPET, - Relations.IS_DRAFT + Relations.SNIPPET ) } diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt index 40a19d132e..c44687a8ee 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt @@ -1416,6 +1416,11 @@ class EditorViewModel( ) { Timber.d("onEndLineEnterClicked, id:[$id] text:[$text] marks:[$marks]") + if (isObjectTypesWidgetVisible) { + dispatchObjectCreateEvent() + proceedWithHidingObjectTypeWidget() + } + val target = blocks.first { it.id == id } val content = target.content().copy( @@ -2902,6 +2907,12 @@ class EditorViewModel( fun onOutsideClicked() { Timber.d("onOutsideClicked, ") + + if (isObjectTypesWidgetVisible) { + dispatchObjectCreateEvent() + proceedWithHidingObjectTypeWidget() + } + if (mode is EditorMode.Styling) { onExitBlockStyleToolbarClicked() return @@ -3132,7 +3143,17 @@ class EditorViewModel( jobs += viewModelScope.launch { createObject.execute(CreateObject.Param(type = null)) .fold( - onSuccess = { result -> proceedWithOpeningObject(result.objectId) }, + onSuccess = { result -> + if (result.appliedTemplate != null) { + sendAnalyticsObjectCreateEvent( + analytics = analytics, + objType = result.type, + route = EventsDictionary.Routes.objPowerTool, + context = analyticsContext + ) + } + proceedWithOpeningObject(result.objectId) + }, onFailure = { e -> Timber.e(e, "Error while creating a new page") } ) } @@ -5876,7 +5897,6 @@ class EditorViewModel( private fun dispatchObjectCreateEvent(objectType: String? = null) { val details = orchestrator.stores.details.current() val wrapper = ObjectWrapper.Basic(details.details[context]?.map ?: emptyMap()) - if (wrapper.isDraft != true) return if (objectType != null) { viewModelScope.launch { val type = storeOfObjectTypes.get(objectType) @@ -5910,15 +5930,6 @@ class EditorViewModel( } } - private fun getObjectSmartBlockType(): SmartBlockType { - val block = blocks.firstOrNull { it.id == context } - return if (block?.content is Content.Smart) { - block.content().type - } else { - SmartBlockType.PAGE - } - } - private fun proceedWithOpeningSelectingObjectTypeScreen() { val excludeTypes = orchestrator.stores.details.current().details[context]?.type val command = if (isObjectTypesWidgetVisible) { diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/extension/AnalyticsExt.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/extension/AnalyticsExt.kt index 1537e37ac3..d378c1db0c 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/extension/AnalyticsExt.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/extension/AnalyticsExt.kt @@ -734,7 +734,7 @@ fun CoroutineScope.sendAnalyticsRemoveSortEvent( fun CoroutineScope.sendAnalyticsObjectCreateEvent( analytics: Analytics, objType: String?, - layout: Double?, + layout: Double? = null, route: String, startTime: Long? = null, middleTime: Long? = null, diff --git a/presentation/src/main/java/com/anytypeio/anytype/presentation/sets/ObjectSetViewModel.kt b/presentation/src/main/java/com/anytypeio/anytype/presentation/sets/ObjectSetViewModel.kt index 59f5c42981..6466c6052c 100644 --- a/presentation/src/main/java/com/anytypeio/anytype/presentation/sets/ObjectSetViewModel.kt +++ b/presentation/src/main/java/com/anytypeio/anytype/presentation/sets/ObjectSetViewModel.kt @@ -50,6 +50,7 @@ import com.anytypeio.anytype.presentation.editor.editor.Proxy import com.anytypeio.anytype.presentation.editor.editor.listener.ListenerType import com.anytypeio.anytype.presentation.editor.editor.model.BlockView import com.anytypeio.anytype.presentation.editor.model.TextUpdate +import com.anytypeio.anytype.presentation.extension.sendAnalyticsObjectCreateEvent import com.anytypeio.anytype.presentation.extension.sendAnalyticsShowSetEvent import com.anytypeio.anytype.presentation.navigation.AppNavigation import com.anytypeio.anytype.presentation.navigation.SupportNavigation @@ -1038,6 +1039,14 @@ class ObjectSetViewModel( jobs += viewModelScope.launch { createObject.execute(CreateObject.Param(type = null)).fold( onSuccess = { result -> + if (result.appliedTemplate != null) { + sendAnalyticsObjectCreateEvent( + analytics = analytics, + objType = result.type, + route = EventsDictionary.Routes.objCreateSet, + context = analyticsContext + ) + } proceedWithOpeningObject(result.objectId) }, onFailure = { e ->