Skip to content

Commit 8116e43

Browse files
committed
Remove unused UserInfoClick action and CopyToClipboardHandler dependency from ChannelInfoViewModel and ChannelInfoViewController.
1 parent 1755bfe commit 8116e43

17 files changed

Lines changed: 13 additions & 92 deletions

File tree

stream-chat-android-compose-sample/src/main/java/io/getstream/chat/android/compose/sample/ui/channel/DirectChannelInfoActivity.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class DirectChannelInfoActivity : ComponentActivity() {
6060

6161
private val viewModelFactory by lazy {
6262
ChannelInfoViewModelFactory(
63-
context = applicationContext,
6463
cid = channelId,
6564
)
6665
}

stream-chat-android-compose-sample/src/main/java/io/getstream/chat/android/compose/sample/ui/channel/GroupChannelInfoActivity.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ class GroupChannelInfoActivity : ComponentActivity() {
6262

6363
private val viewModelFactory by lazy {
6464
ChannelInfoViewModelFactory(
65-
context = applicationContext,
6665
cid = channelId,
6766
)
6867
}

stream-chat-android-compose-sample/src/main/java/io/getstream/chat/android/compose/sample/ui/chats/ChatsActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ class ChatsActivity : ComponentActivity() {
331331
onNavigateToFilesAttachments: () -> Unit,
332332
) {
333333
val viewModelFactory = remember(channelId) {
334-
ChannelInfoViewModelFactory(context = applicationContext, cid = channelId)
334+
ChannelInfoViewModelFactory(cid = channelId)
335335
}
336336
val viewModel = viewModel<ChannelInfoViewModel>(factory = viewModelFactory)
337337

@@ -385,7 +385,7 @@ class ChatsActivity : ComponentActivity() {
385385
onNavigateToChannel: (cid: String) -> Unit,
386386
) {
387387
val viewModelFactory = remember(channelId) {
388-
ChannelInfoViewModelFactory(context = applicationContext, cid = channelId)
388+
ChannelInfoViewModelFactory(cid = channelId)
389389
}
390390
val viewModel = viewModel<ChannelInfoViewModel>(factory = viewModelFactory)
391391

stream-chat-android-compose/api/stream-chat-android-compose.api

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6907,8 +6907,8 @@ public final class io/getstream/chat/android/compose/viewmodel/channel/ChannelIn
69076907

69086908
public final class io/getstream/chat/android/compose/viewmodel/channel/ChannelInfoViewModel : androidx/lifecycle/ViewModel {
69096909
public static final field $stable I
6910-
public fun <init> (Ljava/lang/String;Lio/getstream/chat/android/ui/common/helper/CopyToClipboardHandler;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V
6911-
public synthetic fun <init> (Ljava/lang/String;Lio/getstream/chat/android/ui/common/helper/CopyToClipboardHandler;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
6910+
public fun <init> (Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;)V
6911+
public synthetic fun <init> (Ljava/lang/String;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
69126912
public final fun addMembers (Ljava/util/Set;)V
69136913
public final fun getEvents ()Lkotlinx/coroutines/flow/SharedFlow;
69146914
public final fun getState ()Lkotlinx/coroutines/flow/StateFlow;
@@ -6918,8 +6918,8 @@ public final class io/getstream/chat/android/compose/viewmodel/channel/ChannelIn
69186918

69196919
public final class io/getstream/chat/android/compose/viewmodel/channel/ChannelInfoViewModelFactory : androidx/lifecycle/ViewModelProvider$Factory {
69206920
public static final field $stable I
6921-
public fun <init> (Landroid/content/Context;Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V
6922-
public synthetic fun <init> (Landroid/content/Context;Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
6921+
public fun <init> (Ljava/lang/String;Lkotlin/jvm/functions/Function1;)V
6922+
public synthetic fun <init> (Ljava/lang/String;Lkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
69236923
public fun create (Ljava/lang/Class;)Landroidx/lifecycle/ViewModel;
69246924
}
69256925

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/viewmodel/channel/ChannelInfoViewModel.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import io.getstream.chat.android.ui.common.feature.channel.info.ChannelInfoMembe
2525
import io.getstream.chat.android.ui.common.feature.channel.info.ChannelInfoViewAction
2626
import io.getstream.chat.android.ui.common.feature.channel.info.ChannelInfoViewController
2727
import io.getstream.chat.android.ui.common.feature.channel.info.ChannelInfoViewEvent
28-
import io.getstream.chat.android.ui.common.helper.CopyToClipboardHandler
2928
import io.getstream.chat.android.ui.common.state.channel.info.ChannelInfoViewState
3029
import kotlinx.coroutines.flow.SharedFlow
3130
import kotlinx.coroutines.flow.StateFlow
@@ -34,20 +33,17 @@ import kotlinx.coroutines.flow.StateFlow
3433
* ViewModel for managing channel information and its actions.
3534
*
3635
* @param cid The full channel identifier (e.g., "messaging:123").
37-
* @param copyToClipboardHandler The handler for copying text to the clipboard.
3836
* @param optionFilter A filter function for channel options, allowing customization of which options are displayed.
3937
* Defaults to a function that returns true for all options.
4038
* @param controllerProvider The provider for [ChannelInfoViewController].
4139
*/
4240
public class ChannelInfoViewModel(
4341
private val cid: String,
44-
private val copyToClipboardHandler: CopyToClipboardHandler,
4542
private val optionFilter: (option: ChannelInfoViewState.Content.Option) -> Boolean = { true },
4643
private val controllerProvider: ViewModel.() -> ChannelInfoViewController = {
4744
ChannelInfoViewController(
4845
cid = cid,
4946
scope = viewModelScope,
50-
copyToClipboardHandler = copyToClipboardHandler,
5147
optionFilter = optionFilter,
5248
)
5349
},

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/viewmodel/channel/ChannelInfoViewModelFactory.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,18 @@
1616

1717
package io.getstream.chat.android.compose.viewmodel.channel
1818

19-
import android.content.Context
2019
import androidx.lifecycle.ViewModel
2120
import androidx.lifecycle.ViewModelProvider
22-
import io.getstream.chat.android.ui.common.helper.CopyToClipboardHandler
2321
import io.getstream.chat.android.ui.common.state.channel.info.ChannelInfoViewState
2422

2523
/**
2624
* Factory for creating instances of [ChannelInfoViewModel].
2725
*
28-
* @param context The application context.
2926
* @param cid The full channel identifier (Ex. "messaging:123").
3027
* @param optionFilter A filter function for channel options, allowing customization of which options are displayed.
3128
* Defaults to a function that returns true for all options.
3229
*/
3330
public class ChannelInfoViewModelFactory(
34-
private val context: Context,
3531
private val cid: String,
3632
private val optionFilter: (option: ChannelInfoViewState.Content.Option) -> Boolean = { true },
3733
) : ViewModelProvider.Factory {
@@ -41,7 +37,6 @@ public class ChannelInfoViewModelFactory(
4137
ChannelInfoViewModel::class.java to {
4238
ChannelInfoViewModel(
4339
cid = cid,
44-
copyToClipboardHandler = CopyToClipboardHandler(context = context.applicationContext),
4540
optionFilter = optionFilter,
4641
)
4742
},

stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/viewmodel/channel/ChannelInfoViewModelFactoryTest.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@
1616

1717
package io.getstream.chat.android.compose.viewmodel.channel
1818

19-
import android.content.Context
2019
import androidx.lifecycle.ViewModel
2120
import io.getstream.chat.android.randomCID
2221
import org.junit.Assert.assertEquals
2322
import org.junit.Assert.assertThrows
2423
import org.junit.Test
2524
import org.junit.jupiter.api.assertInstanceOf
26-
import org.mockito.kotlin.doReturn
27-
import org.mockito.kotlin.mock
2825

2926
internal class ChannelInfoViewModelFactoryTest {
3027

@@ -71,12 +68,7 @@ internal class ChannelInfoViewModelFactoryTest {
7168
}
7269

7370
private class Fixture {
74-
private val mockContext: Context = mock {
75-
on { applicationContext } doReturn it
76-
}
77-
7871
fun get() = ChannelInfoViewModelFactory(
79-
context = mockContext,
8072
cid = randomCID(),
8173
)
8274
}

stream-chat-android-compose/src/test/kotlin/io/getstream/chat/android/compose/viewmodel/channel/ChannelInfoViewModelTest.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package io.getstream.chat.android.compose.viewmodel.channel
1919
import app.cash.turbine.test
2020
import io.getstream.chat.android.randomCID
2121
import io.getstream.chat.android.randomMember
22-
import io.getstream.chat.android.randomUser
2322
import io.getstream.chat.android.ui.common.feature.channel.info.ChannelInfoMemberViewEvent
2423
import io.getstream.chat.android.ui.common.feature.channel.info.ChannelInfoViewAction
2524
import io.getstream.chat.android.ui.common.feature.channel.info.ChannelInfoViewController
@@ -72,7 +71,7 @@ internal class ChannelInfoViewModelTest {
7271
val fixture = Fixture()
7372
val sut = fixture.get()
7473

75-
val action = ChannelInfoViewAction.UserInfoClick(user = randomUser())
74+
val action = ChannelInfoViewAction.PinnedMessagesClick
7675
sut.onViewAction(action)
7776

7877
fixture.verifyControllerOnViewAction(action)
@@ -110,7 +109,6 @@ internal class ChannelInfoViewModelTest {
110109

111110
fun get() = ChannelInfoViewModel(
112111
cid = randomCID(),
113-
copyToClipboardHandler = mock(),
114112
optionFilter = mock(),
115113
controllerProvider = { mockController },
116114
)

stream-chat-android-ui-common/api/stream-chat-android-ui-common.api

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -446,18 +446,6 @@ public final class io/getstream/chat/android/ui/common/feature/channel/info/Chan
446446
public fun toString ()Ljava/lang/String;
447447
}
448448

449-
public final class io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoViewAction$UserInfoClick : io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoViewAction {
450-
public static final field $stable I
451-
public fun <init> (Lio/getstream/chat/android/models/User;)V
452-
public final fun component1 ()Lio/getstream/chat/android/models/User;
453-
public final fun copy (Lio/getstream/chat/android/models/User;)Lio/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoViewAction$UserInfoClick;
454-
public static synthetic fun copy$default (Lio/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoViewAction$UserInfoClick;Lio/getstream/chat/android/models/User;ILjava/lang/Object;)Lio/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoViewAction$UserInfoClick;
455-
public fun equals (Ljava/lang/Object;)Z
456-
public final fun getUser ()Lio/getstream/chat/android/models/User;
457-
public fun hashCode ()I
458-
public fun toString ()Ljava/lang/String;
459-
}
460-
461449
public abstract interface class io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoViewEvent {
462450
}
463451

stream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/feature/channel/info/ChannelInfoViewAction.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package io.getstream.chat.android.ui.common.feature.channel.info
1818

1919
import io.getstream.chat.android.models.Member
2020
import io.getstream.chat.android.models.Message
21-
import io.getstream.chat.android.models.User
2221

2322
/**
2423
* Represents actions that can be performed from the channel information view.
@@ -41,13 +40,6 @@ public sealed interface ChannelInfoViewAction {
4140
*/
4241
public data class MemberClick(val member: Member) : ChannelInfoViewAction
4342

44-
/**
45-
* Represents the user info click action.
46-
*
47-
* @param user The clicked user.
48-
*/
49-
public data class UserInfoClick(val user: User) : ChannelInfoViewAction
50-
5143
/**
5244
* Represents the rename channel click action.
5345
*

0 commit comments

Comments
 (0)