mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-2794 Editor | Fix | Mention object type name (#1887)
This commit is contained in:
parent
fec4c35163
commit
2f1bc2633b
2 changed files with 20 additions and 16 deletions
|
@ -1,7 +1,9 @@
|
|||
package com.anytypeio.anytype.domain.primitives
|
||||
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.MAX_SNIPPET_SIZE
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.ObjectTypeIds
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.Relations
|
||||
import com.anytypeio.anytype.core_models.RelativeDate
|
||||
|
@ -29,10 +31,10 @@ interface FieldParser {
|
|||
)
|
||||
|
||||
fun getObjectName(objectWrapper: ObjectWrapper.Basic): String
|
||||
fun getObjectTypeName(
|
||||
fun getObjectTypeIdAndName(
|
||||
objectWrapper: ObjectWrapper.Basic,
|
||||
types: List<ObjectWrapper.Type>
|
||||
): String?
|
||||
): Pair<Id?, String?>
|
||||
}
|
||||
|
||||
class FieldParserImpl @Inject constructor(
|
||||
|
@ -111,18 +113,19 @@ class FieldParserImpl @Inject constructor(
|
|||
return objectWrapper.getProperObjectName().orEmpty()
|
||||
}
|
||||
|
||||
override fun getObjectTypeName(
|
||||
override fun getObjectTypeIdAndName(
|
||||
objectWrapper: ObjectWrapper.Basic,
|
||||
types: List<ObjectWrapper.Type>
|
||||
): String? {
|
||||
return when (objectWrapper.layout) {
|
||||
ObjectType.Layout.DATE -> {
|
||||
return null
|
||||
}
|
||||
): Pair<Id?, String?> {
|
||||
val id = when (objectWrapper.layout) {
|
||||
ObjectType.Layout.DATE -> ObjectTypeIds.DATE
|
||||
else -> objectWrapper.type.firstOrNull()
|
||||
}
|
||||
|
||||
else -> {
|
||||
types.find { it.id == objectWrapper.id }?.name
|
||||
}
|
||||
return if (id != null) {
|
||||
id to types.find { it.id == id }?.name
|
||||
} else {
|
||||
null to null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.anytypeio.anytype.presentation.objects
|
||||
|
||||
import com.anytypeio.anytype.core_models.Id
|
||||
import com.anytypeio.anytype.core_models.MarketplaceObjectTypeIds
|
||||
import com.anytypeio.anytype.core_models.ObjectType
|
||||
import com.anytypeio.anytype.core_models.ObjectTypeUniqueKeys
|
||||
import com.anytypeio.anytype.core_models.ObjectWrapper
|
||||
import com.anytypeio.anytype.core_models.ext.DateParser
|
||||
import com.anytypeio.anytype.core_utils.ext.readableFileSize
|
||||
|
@ -29,14 +27,17 @@ fun ObjectWrapper.Basic.toView(
|
|||
fieldParser: FieldParser
|
||||
): DefaultObjectView {
|
||||
val obj = this
|
||||
val typeUrl = obj.getProperType()
|
||||
val (objTypeId, objTypeName) = fieldParser.getObjectTypeIdAndName(
|
||||
objectWrapper = obj,
|
||||
types = objectTypes
|
||||
)
|
||||
val layout = obj.getProperLayout()
|
||||
return DefaultObjectView(
|
||||
id = obj.id,
|
||||
name = fieldParser.getObjectName(obj),
|
||||
description = obj.description,
|
||||
type = typeUrl,
|
||||
typeName = fieldParser.getObjectTypeName(obj, objectTypes),
|
||||
type = objTypeId,
|
||||
typeName = objTypeName,
|
||||
layout = layout,
|
||||
icon = obj.objectIcon(urlBuilder),
|
||||
lastModifiedDate = DateParser.parseInMillis(obj.lastModifiedDate) ?: 0L,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue