Skip to content

Commit

Permalink
#5327 moved key to ChannelsScreen.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
GusWard authored and JcMinarro committed Jul 23, 2024
1 parent 967b6ad commit 7e2721c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ public final class io/getstream/chat/android/compose/ui/attachments/preview/hand
}

public final class io/getstream/chat/android/compose/ui/channels/ChannelsScreenKt {
public static final fun ChannelsScreen (Lio/getstream/chat/android/compose/viewmodel/channels/ChannelViewModelFactory;Ljava/lang/String;ZLio/getstream/chat/android/compose/ui/channels/SearchMode;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;Landroidx/compose/runtime/Composer;II)V
public static final fun ChannelsScreen (Lio/getstream/chat/android/compose/viewmodel/channels/ChannelViewModelFactory;Ljava/lang/String;Ljava/lang/String;ZLio/getstream/chat/android/compose/ui/channels/SearchMode;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function0;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function0;Landroidx/compose/runtime/Composer;III)V
}

public final class io/getstream/chat/android/compose/ui/channels/SearchMode : java/lang/Enum {
Expand Down Expand Up @@ -2298,10 +2298,9 @@ public final class io/getstream/chat/android/compose/viewmodel/channels/ChannelL
public final class io/getstream/chat/android/compose/viewmodel/channels/ChannelViewModelFactory : androidx/lifecycle/ViewModelProvider$Factory {
public static final field $stable I
public fun <init> ()V
public fun <init> (Lio/getstream/chat/android/client/ChatClient;Lio/getstream/chat/android/models/querysort/QuerySorter;Lio/getstream/chat/android/models/FilterObject;IIILio/getstream/chat/android/state/event/handler/chat/factory/ChatEventHandlerFactory;Ljava/lang/String;)V
public synthetic fun <init> (Lio/getstream/chat/android/client/ChatClient;Lio/getstream/chat/android/models/querysort/QuerySorter;Lio/getstream/chat/android/models/FilterObject;IIILio/getstream/chat/android/state/event/handler/chat/factory/ChatEventHandlerFactory;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun <init> (Lio/getstream/chat/android/client/ChatClient;Lio/getstream/chat/android/models/querysort/QuerySorter;Lio/getstream/chat/android/models/FilterObject;IIILio/getstream/chat/android/state/event/handler/chat/factory/ChatEventHandlerFactory;)V
public synthetic fun <init> (Lio/getstream/chat/android/client/ChatClient;Lio/getstream/chat/android/models/querysort/QuerySorter;Lio/getstream/chat/android/models/FilterObject;IIILio/getstream/chat/android/state/event/handler/chat/factory/ChatEventHandlerFactory;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun create (Ljava/lang/Class;)Landroidx/lifecycle/ViewModel;
public final fun getViewModelKey ()Ljava/lang/String;
}

public final class io/getstream/chat/android/compose/viewmodel/mediapreview/MediaGalleryPreviewViewModel : androidx/lifecycle/ViewModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ import io.getstream.chat.android.ui.common.state.channels.actions.ViewInfo
* @param viewModelFactory The factory used to build the ViewModels and power the behavior.
* You can use the default implementation by not passing in an instance yourself, or you
* can customize the behavior using its parameters.
* @param viewModelKey Key to differentiate between instances of [ChannelListViewModel].
* @param title Header title.
* @param isShowingHeader If we show the header or hide it.
* @param searchMode The search mode for the screen.
Expand All @@ -87,6 +88,7 @@ import io.getstream.chat.android.ui.common.state.channels.actions.ViewInfo
@Suppress("LongMethod")
public fun ChannelsScreen(
viewModelFactory: ChannelViewModelFactory = ChannelViewModelFactory(),
viewModelKey: String? = null,
title: String = "Stream Chat",
isShowingHeader: Boolean = true,
searchMode: SearchMode = SearchMode.None,
Expand All @@ -99,7 +101,7 @@ public fun ChannelsScreen(
) {
val listViewModel: ChannelListViewModel = viewModel(
ChannelListViewModel::class.java,
key = viewModelFactory.viewModelKey,
key = viewModelKey,
factory = viewModelFactory,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import io.getstream.chat.android.state.event.handler.chat.factory.ChatEventHandl
* @param memberLimit How many members are fetched for each channel item when loading channels.
* @param messageLimit How many messages are fetched for each channel item when loading channels.
* @param chatEventHandlerFactory The instance of [ChatEventHandlerFactory] used to create [ChatEventHandler].
* @param viewModelKey Optional key for for cases where the app needs multiple instances with varying parameters.
*/
public class ChannelViewModelFactory(
private val chatClient: ChatClient = ChatClient.instance(),
Expand All @@ -47,7 +46,6 @@ public class ChannelViewModelFactory(
private val memberLimit: Int = ChannelListViewModel.DEFAULT_MEMBER_LIMIT,
private val messageLimit: Int = ChannelListViewModel.DEFAULT_MESSAGE_LIMIT,
private val chatEventHandlerFactory: ChatEventHandlerFactory = ChatEventHandlerFactory(chatClient.clientState),
public val viewModelKey: String? = null,
) : ViewModelProvider.Factory {

private val factories: Map<Class<*>, () -> ViewModel> = mapOf(
Expand Down

0 comments on commit 7e2721c

Please sign in to comment.