Skip to content

Commit 98186c3

Browse files
committed
Provide a ChatClient lazily in ChatNotifications
1 parent 07317a2 commit 98186c3

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

stream-chat-android-client/src/main/java/io/getstream/chat/android/client/notifications/ChatNotifications.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ internal class ChatNotificationsImpl(
5757
private val notificationConfig: NotificationConfig,
5858
private val context: Context,
5959
private val scope: CoroutineScope = CoroutineScope(DispatcherProvider.IO),
60-
private val chatClient: ChatClient = ChatClient.instance(),
60+
private val chatClientProvider: () -> ChatClient = { ChatClient.instance() },
6161
) : ChatNotifications {
6262
private val logger by taggedLogger("Chat:Notifications")
6363

64+
private val chatClient: ChatClient by lazy { chatClientProvider() }
6465
private val pushTokenUpdateHandler = PushTokenUpdateHandler()
6566
private val showedMessages = mutableSetOf<String>()
6667
private val permissionManager: NotificationPermissionManager =

stream-chat-android-client/src/test/java/io/getstream/chat/android/client/notifications/ChatNotificationsImplTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ internal class ChatNotificationsImplTest {
144144
notificationConfig = notificationConfig,
145145
context = context,
146146
scope = mock(),
147-
chatClient = mockChatClient,
147+
chatClientProvider = { mockChatClient },
148148
)
149149
}
150150
}

0 commit comments

Comments
 (0)