From c6c5b1dac25fa11923e8db5d5d155ea6e9d9503f Mon Sep 17 00:00:00 2001 From: Evgenii Kozlov Date: Fri, 23 May 2025 14:04:59 +0200 Subject: [PATCH] DROID-2966 Chat | Fix | Misc. fixes (#2441) --- .../anytype/ui/chats/ChatFragment.kt | 5 ++- .../anytype/ui/home/HomeScreenFragment.kt | 4 ++- .../anytypeio/anytype/core_models/Command.kt | 3 +- .../domain/icon/SetDocumentImageIcon.kt | 3 +- .../anytype/domain/icon/SetImageIcon.kt | 3 +- .../anytype/domain/icon/SetTextBlockImage.kt | 3 +- .../anytype/domain/media/UploadFile.kt | 4 ++- .../presentation/ChatViewModel.kt | 34 ++++++++++--------- .../account/ProfileSettingsViewModel.kt | 3 +- .../space/new_settings/NewSettings.kt | 13 +++---- .../middleware/interactor/Middleware.kt | 2 +- 11 files changed, 43 insertions(+), 34 deletions(-) diff --git a/app/src/main/java/com/anytypeio/anytype/ui/chats/ChatFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/chats/ChatFragment.kt index af55b4796b..031efe126c 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/chats/ChatFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/chats/ChatFragment.kt @@ -10,9 +10,12 @@ import androidx.activity.compose.BackHandler import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.result.contract.ActivityResultContracts import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.layout.systemBarsPadding +import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.MaterialTheme import androidx.compose.material3.ExperimentalMaterial3Api @@ -94,7 +97,7 @@ class ChatFragment : BaseComposeFragment() { Column( modifier = Modifier .fillMaxSize() - .systemBarsPadding() + .windowInsetsPadding(WindowInsets.statusBars) ) { ChatTopToolbar( header = vm.header.collectAsStateWithLifecycle().value, diff --git a/app/src/main/java/com/anytypeio/anytype/ui/home/HomeScreenFragment.kt b/app/src/main/java/com/anytypeio/anytype/ui/home/HomeScreenFragment.kt index 9d6c4b4d50..7eb4199fca 100644 --- a/app/src/main/java/com/anytypeio/anytype/ui/home/HomeScreenFragment.kt +++ b/app/src/main/java/com/anytypeio/anytype/ui/home/HomeScreenFragment.kt @@ -7,9 +7,12 @@ import android.view.ViewGroup import android.widget.Toast import androidx.activity.compose.BackHandler import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.statusBars import androidx.compose.foundation.layout.systemBarsPadding +import androidx.compose.foundation.layout.windowInsetsPadding import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.MaterialTheme import androidx.compose.material3.ExperimentalMaterial3Api @@ -114,7 +117,6 @@ class HomeScreenFragment : BaseComposeFragment(), Box( modifier = Modifier .fillMaxSize() - .systemBarsPadding() ) { HomeScreenToolbar( spaceIconView = view?.icon ?: SpaceIconView.Loading, diff --git a/core-models/src/main/java/com/anytypeio/anytype/core_models/Command.kt b/core-models/src/main/java/com/anytypeio/anytype/core_models/Command.kt index 389a9e712e..35ae02f2ce 100644 --- a/core-models/src/main/java/com/anytypeio/anytype/core_models/Command.kt +++ b/core-models/src/main/java/com/anytypeio/anytype/core_models/Command.kt @@ -35,7 +35,8 @@ sealed class Command { class UploadFile( val space: SpaceId, val path: String, - val type: Block.Content.File.Type? + val type: Block.Content.File.Type?, + val createTypeWidgetIfMissing: Boolean = true ) class FileDrop( diff --git a/domain/src/main/java/com/anytypeio/anytype/domain/icon/SetDocumentImageIcon.kt b/domain/src/main/java/com/anytypeio/anytype/domain/icon/SetDocumentImageIcon.kt index ea7381234e..53b1310f3c 100644 --- a/domain/src/main/java/com/anytypeio/anytype/domain/icon/SetDocumentImageIcon.kt +++ b/domain/src/main/java/com/anytypeio/anytype/domain/icon/SetDocumentImageIcon.kt @@ -15,7 +15,8 @@ class SetDocumentImageIcon @Inject constructor( command = Command.UploadFile( path = params.path, type = Block.Content.File.Type.IMAGE, - space = params.spaceId + space = params.spaceId, + createTypeWidgetIfMissing = params.createTypeWidgetIfMissing ) ) val payload = repo.setDocumentImageIcon( diff --git a/domain/src/main/java/com/anytypeio/anytype/domain/icon/SetImageIcon.kt b/domain/src/main/java/com/anytypeio/anytype/domain/icon/SetImageIcon.kt index 80938533b1..282129be74 100644 --- a/domain/src/main/java/com/anytypeio/anytype/domain/icon/SetImageIcon.kt +++ b/domain/src/main/java/com/anytypeio/anytype/domain/icon/SetImageIcon.kt @@ -14,6 +14,7 @@ abstract class SetImageIcon : BaseUseCase, SetImageIcon.P data class Params( val target: T, val path: String, - val spaceId: SpaceId + val spaceId: SpaceId, + val createTypeWidgetIfMissing: Boolean = true ) } \ No newline at end of file diff --git a/domain/src/main/java/com/anytypeio/anytype/domain/icon/SetTextBlockImage.kt b/domain/src/main/java/com/anytypeio/anytype/domain/icon/SetTextBlockImage.kt index e6edc10b05..385c89c43d 100644 --- a/domain/src/main/java/com/anytypeio/anytype/domain/icon/SetTextBlockImage.kt +++ b/domain/src/main/java/com/anytypeio/anytype/domain/icon/SetTextBlockImage.kt @@ -15,7 +15,8 @@ class SetTextBlockImage( command = Command.UploadFile( path = params.path, type = Block.Content.File.Type.IMAGE, - space = params.spaceId + space = params.spaceId, + createTypeWidgetIfMissing = params.createTypeWidgetIfMissing ) ) val payload = repo.setTextIcon( diff --git a/domain/src/main/java/com/anytypeio/anytype/domain/media/UploadFile.kt b/domain/src/main/java/com/anytypeio/anytype/domain/media/UploadFile.kt index 4a6c4ac60e..fd085085ca 100644 --- a/domain/src/main/java/com/anytypeio/anytype/domain/media/UploadFile.kt +++ b/domain/src/main/java/com/anytypeio/anytype/domain/media/UploadFile.kt @@ -19,7 +19,8 @@ class UploadFile @Inject constructor( command = Command.UploadFile( path = params.path, type = params.type, - space = params.space + space = params.space, + createTypeWidgetIfMissing = params.createTypeWidgetIfMissing ) ) @@ -27,5 +28,6 @@ class UploadFile @Inject constructor( val path: String, val space: SpaceId, val type: Block.Content.File.Type = Block.Content.File.Type.FILE, + val createTypeWidgetIfMissing: Boolean = true ) } \ No newline at end of file diff --git a/feature-chats/src/main/java/com/anytypeio/anytype/feature_chats/presentation/ChatViewModel.kt b/feature-chats/src/main/java/com/anytypeio/anytype/feature_chats/presentation/ChatViewModel.kt index 2137a91407..8a3bdc612d 100644 --- a/feature-chats/src/main/java/com/anytypeio/anytype/feature_chats/presentation/ChatViewModel.kt +++ b/feature-chats/src/main/java/com/anytypeio/anytype/feature_chats/presentation/ChatViewModel.kt @@ -390,23 +390,25 @@ class ChatViewModel @Inject constructor( val results = members.get().let { store -> when (store) { is Store.Data -> { - store.members.map { member -> - MentionPanelState.Member( - member.id, - name = member.name.orEmpty(), - icon = SpaceMemberIconView.icon( - obj = member, - urlBuilder = urlBuilder - ), - isUser = member.identity == account - ) - }.filter { m -> - if (query != null) { - m.name.contains(query.query, true) - } else { - true + store.members + .filter { member -> member.permissions?.isAtLeastReader() == true } + .map { member -> + MentionPanelState.Member( + member.id, + name = member.name.orEmpty(), + icon = SpaceMemberIconView.icon( + obj = member, + urlBuilder = urlBuilder + ), + isUser = member.identity == account + ) + }.filter { m -> + if (query != null) { + m.name.contains(query.query, true) + } else { + true + } } - } } Store.Empty -> { diff --git a/feature-ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/account/ProfileSettingsViewModel.kt b/feature-ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/account/ProfileSettingsViewModel.kt index d51ec91143..6b41aaa6a8 100644 --- a/feature-ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/account/ProfileSettingsViewModel.kt +++ b/feature-ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/account/ProfileSettingsViewModel.kt @@ -133,7 +133,8 @@ class ProfileSettingsViewModel( SetImageIcon.Params( target = config.profile, path = path, - spaceId = SpaceId(config.techSpace) + spaceId = SpaceId(config.techSpace), + createTypeWidgetIfMissing = false ) ).process( failure = { diff --git a/feature-ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/space/new_settings/NewSettings.kt b/feature-ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/space/new_settings/NewSettings.kt index 8cba220e81..80a222d5b9 100644 --- a/feature-ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/space/new_settings/NewSettings.kt +++ b/feature-ui-settings/src/main/java/com/anytypeio/anytype/ui_settings/space/new_settings/NewSettings.kt @@ -78,15 +78,10 @@ fun NewSpaceSettingsScreen( containerColor = colorResource(id = R.color.background_primary), topBar = { Box( - modifier = if (Build.VERSION.SDK_INT >= EDGE_TO_EDGE_MIN_SDK) - Modifier - .windowInsetsPadding(WindowInsets.statusBars) - .fillMaxWidth() - .height(48.dp) - else - Modifier - .fillMaxWidth() - .height(48.dp) + modifier = Modifier + .windowInsetsPadding(WindowInsets.statusBars) + .fillMaxWidth() + .height(48.dp) ) { Box( modifier = Modifier diff --git a/middleware/src/main/java/com/anytypeio/anytype/middleware/interactor/Middleware.kt b/middleware/src/main/java/com/anytypeio/anytype/middleware/interactor/Middleware.kt index f39984ede4..43de24d6d2 100644 --- a/middleware/src/main/java/com/anytypeio/anytype/middleware/interactor/Middleware.kt +++ b/middleware/src/main/java/com/anytypeio/anytype/middleware/interactor/Middleware.kt @@ -830,7 +830,7 @@ class Middleware @Inject constructor( localPath = command.path, type = type, spaceId = command.space.id, - createTypeWidgetIfMissing = true + createTypeWidgetIfMissing = command.createTypeWidgetIfMissing ) logRequestIfDebug(request) val (response, time) = measureTimedValue { service.fileUpload(request) }