mirror of
https://github.com/anyproto/anytype-kotlin.git
synced 2025-06-08 05:47:05 +09:00
DROID-3692 Space settings | Fix | Different number of members on Space settings screen and Members screen (#2450)
This commit is contained in:
parent
7f98cdfaaa
commit
e685e4ea53
4 changed files with 30 additions and 8 deletions
|
@ -12,9 +12,9 @@ fun DecryptedPushContent.Message.formatNotificationBody(attachmentText: String):
|
|||
val rawText = text.trim()
|
||||
return when {
|
||||
hasAttachments && rawText.isNotEmpty() ->
|
||||
"$rawText \uD83D\uDCCE$attachmentText"
|
||||
"$rawText \uD83D\uDCCE $attachmentText"
|
||||
hasAttachments ->
|
||||
"\uD83D\uDCCE$attachmentText"
|
||||
"\uD83D\uDCCE $attachmentText"
|
||||
else ->
|
||||
rawText
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.anytypeio.anytype.analytics.base.Analytics
|
|||
import com.anytypeio.anytype.core_utils.di.scope.PerScreen
|
||||
import com.anytypeio.anytype.device.share.debug.DebugSpaceDeviceFileContentSaver
|
||||
import com.anytypeio.anytype.di.common.ComponentDependencies
|
||||
import com.anytypeio.anytype.domain.auth.interactor.GetAccount
|
||||
import com.anytypeio.anytype.domain.auth.repo.AuthRepository
|
||||
import com.anytypeio.anytype.domain.base.AppCoroutineDispatchers
|
||||
import com.anytypeio.anytype.domain.block.repo.BlockRepository
|
||||
|
@ -89,6 +90,14 @@ object SpaceSettingsModule {
|
|||
repo = repository
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
@Provides
|
||||
@PerScreen
|
||||
fun provideGetAccountUseCase(
|
||||
repo: AuthRepository,
|
||||
dispatchers: AppCoroutineDispatchers
|
||||
): GetAccount = GetAccount(repo = repo, dispatcher = dispatchers)
|
||||
|
||||
@Module
|
||||
interface Bindings {
|
||||
|
||||
|
|
|
@ -15,13 +15,13 @@ class NotificationExtensionsTest {
|
|||
@Test
|
||||
fun `formatNotificationBody appends attachment indicator when only attachments present`() {
|
||||
val message = createMessage(text = "", hasAttachments = true)
|
||||
assertEquals("\uD83D\uDCCEattachment", message.formatNotificationBody("attachment"))
|
||||
assertEquals("\uD83D\uDCCE attachment", message.formatNotificationBody("attachment"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `formatNotificationBody appends attachment indicator after text when both present`() {
|
||||
val message = createMessage(text = "Hello world", hasAttachments = true)
|
||||
assertEquals("Hello world \uD83D\uDCCEattachment", message.formatNotificationBody("attachment"))
|
||||
assertEquals("Hello world \uD83D\uDCCE attachment", message.formatNotificationBody("attachment"))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -48,7 +48,9 @@ import com.anytypeio.anytype.domain.spaces.SetSpaceDetails
|
|||
import com.anytypeio.anytype.domain.spaces.SetSpaceDetails.*
|
||||
import com.anytypeio.anytype.domain.wallpaper.ObserveWallpaper
|
||||
import com.anytypeio.anytype.domain.workspace.SpaceManager
|
||||
import com.anytypeio.anytype.domain.auth.interactor.GetAccount
|
||||
import com.anytypeio.anytype.presentation.common.BaseViewModel
|
||||
import com.anytypeio.anytype.presentation.mapper.toView
|
||||
import com.anytypeio.anytype.presentation.objects.ObjectIcon
|
||||
import com.anytypeio.anytype.presentation.spaces.SpaceSettingsViewModel.Command.*
|
||||
import com.anytypeio.anytype.presentation.spaces.UiSpaceSettingsItem.*
|
||||
|
@ -85,7 +87,8 @@ class SpaceSettingsViewModel(
|
|||
private val appActionManager: AppActionManager,
|
||||
private val getSpaceInviteLink: GetSpaceInviteLink,
|
||||
private val fetchObject: FetchObject,
|
||||
private val setObjectDetails: SetObjectDetails
|
||||
private val setObjectDetails: SetObjectDetails,
|
||||
private val getAccount: GetAccount
|
||||
): BaseViewModel() {
|
||||
|
||||
val commands = MutableSharedFlow<Command>()
|
||||
|
@ -175,6 +178,9 @@ class SpaceSettingsViewModel(
|
|||
)
|
||||
}
|
||||
|
||||
// Get account for toView function
|
||||
val account = getAccount.async(Unit).getOrNull()?.id
|
||||
|
||||
combine(
|
||||
restrictions,
|
||||
otherFlows
|
||||
|
@ -190,7 +196,12 @@ class SpaceSettingsViewModel(
|
|||
val createdByNameOrId = spaceCreator?.globalName?.takeIf { it.isNotEmpty() } ?: spaceCreator?.identity
|
||||
|
||||
val spaceMemberCount = if (spaceMembers is ActiveSpaceMemberSubscriptionContainer.Store.Data) {
|
||||
spaceMembers.members.size
|
||||
spaceMembers.members.toView(
|
||||
spaceView = spaceView,
|
||||
urlBuilder = urlBuilder,
|
||||
isCurrentUserOwner = permission?.isOwner() == true,
|
||||
account = account
|
||||
).size
|
||||
} else {
|
||||
0
|
||||
}
|
||||
|
@ -770,7 +781,8 @@ class SpaceSettingsViewModel(
|
|||
private val storeOfObjectTypes: StoreOfObjectTypes,
|
||||
private val getSpaceInviteLink: GetSpaceInviteLink,
|
||||
private val fetchObject: FetchObject,
|
||||
private val setObjectDetails: SetObjectDetails
|
||||
private val setObjectDetails: SetObjectDetails,
|
||||
private val getAccount: GetAccount
|
||||
) : ViewModelProvider.Factory {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun <T : ViewModel> create(
|
||||
|
@ -798,7 +810,8 @@ class SpaceSettingsViewModel(
|
|||
storeOfObjectTypes = storeOfObjectTypes,
|
||||
getSpaceInviteLink = getSpaceInviteLink,
|
||||
fetchObject = fetchObject,
|
||||
setObjectDetails = setObjectDetails
|
||||
setObjectDetails = setObjectDetails,
|
||||
getAccount = getAccount
|
||||
) as T
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue