DROID-2144 Object | Fix | Use default object type or fallback to 'Note' type when creating object from clipboard in the new any-object-creation panel (#790)

This commit is contained in:
Evgenii Kozlov 2024-01-20 11:24:16 +01:00 committed by GitHub
parent 05fcf8aebb
commit 04af82dc74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View File

@ -22,7 +22,7 @@ class CreatePrefilledNote @Inject constructor(
override suspend fun doWork(params: Params): Id {
val obj = repo.createObject(
Command.CreateObject(
typeKey = TypeKey(ObjectTypeUniqueKeys.NOTE),
typeKey = params.customType ?: TypeKey(ObjectTypeUniqueKeys.NOTE),
space = SpaceId(params.space),
template = null,
internalFlags = emptyList(),
@ -43,9 +43,13 @@ class CreatePrefilledNote @Inject constructor(
return obj.id
}
/**
* @param [customType] provide custom type instead of note if needed
*/
data class Params(
val space: Id,
val text: String,
val details: Struct
val details: Struct,
val customType: TypeKey? = null
)
}

View File

@ -475,6 +475,12 @@ class SelectObjectTypeViewModel(
private fun proceedWithCreatingNote(text: String) {
viewModelScope.launch {
val startTime = System.currentTimeMillis()
val defaultObjectType = getDefaultObjectType.async(Unit).getOrNull()?.type?.let {
if (it.key != ObjectTypeUniqueKeys.COLLECTION && it.key != ObjectTypeUniqueKeys.SET)
it
else
null
}
createPrefilledNote.async(
CreatePrefilledNote.Params(
text = text,