Skip to content

Commit

Permalink
Set a default value for fields that use @InternalStreamChatApi to a…
Browse files Browse the repository at this point in the history
…void the needed of impolement it on customer's implmenetaiton
  • Loading branch information
JcMinarro committed Jul 11, 2024
1 parent da98076 commit 7aa9aa6
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2525,6 +2525,7 @@ public abstract interface class io/getstream/chat/android/client/plugin/Plugin :
}

public final class io/getstream/chat/android/client/plugin/Plugin$DefaultImpls {
public static fun getErrorHandler (Lio/getstream/chat/android/client/plugin/Plugin;)Lio/getstream/chat/android/client/errorhandler/ErrorHandler;
public static fun onAttachmentSendRequest (Lio/getstream/chat/android/client/plugin/Plugin;Ljava/lang/String;Ljava/lang/String;Lio/getstream/chat/android/models/Message;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static fun onChannelMarkReadPrecondition (Lio/getstream/chat/android/client/plugin/Plugin;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static fun onCreateChannelPrecondition (Lio/getstream/chat/android/client/plugin/Plugin;Lio/getstream/chat/android/models/User;Ljava/lang/String;Ljava/util/List;)Lio/getstream/result/Result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ internal constructor(
* Error handlers for API calls.
*/
private val errorHandlers: List<ErrorHandler>
get() = plugins.mapNotNull { it.errorHandler }.sorted()
get() = plugins.mapNotNull { it.getErrorHandler() }.sorted()

public var logicRegistry: ChannelStateLogicProvider? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ public interface DependencyResolver {
* @see [KClass] to look for.
*/
@InternalStreamChatApi
public fun <T : Any> resolveDependency(klass: KClass<T>): T?
public fun <T : Any> resolveDependency(klass: KClass<T>): T? = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public interface Plugin :
GetMessageListener,
FetchCurrentUserListener {

public val errorHandler: ErrorHandler?
public fun getErrorHandler(): ErrorHandler? = null

override suspend fun onQueryMembersResult(
result: Result<List<Member>>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import io.getstream.result.Result
import kotlin.reflect.KClass

internal class ThrottlingPlugin : Plugin {
override val errorHandler = null
private val lastMarkReadMap: MutableMap<String, Long> = mutableMapOf()

override suspend fun onChannelMarkReadPrecondition(channelType: String, channelId: String): Result<Unit> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package io.getstream.chat.android.client

import io.getstream.chat.android.client.errorhandler.ErrorHandler
import io.getstream.chat.android.client.plugin.Plugin
import io.getstream.chat.android.client.plugin.factory.PluginFactory
import io.getstream.chat.android.client.scope.ClientTestScope
Expand Down Expand Up @@ -183,7 +182,6 @@ public class DependencyResolverTest {
private class PluginDependency(
private val classes: Map<KClass<*>, Any>,
) : Plugin {
override val errorHandler: ErrorHandler? = null
override fun onUserSet(user: User) {
/** NO-OP */
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package io.getstream.chat.android.offline.plugin.internal

import io.getstream.chat.android.client.errorhandler.ErrorHandler
import io.getstream.chat.android.client.plugin.Plugin
import io.getstream.chat.android.client.plugin.listeners.CreateChannelListener
import io.getstream.chat.android.client.plugin.listeners.DeleteChannelListener
Expand Down Expand Up @@ -93,8 +92,6 @@ internal class OfflinePlugin(
GetMessageListener by getMessageListener,
FetchCurrentUserListener by fetchCurrentUserListener {

override val errorHandler: ErrorHandler? = null

override fun onUserSet(user: User) {
/* No-Op */
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ public class StatePlugin internal constructor(
SendAttachmentListener by SendAttachmentListenerState(logic),
FetchCurrentUserListener by FetchCurrentUserListenerState(clientState, globalState) {

override var errorHandler: ErrorHandler = errorHandlerFactory.create()
private val lazyErrorHandler: ErrorHandler by lazy { errorHandlerFactory.create() }
override fun getErrorHandler(): ErrorHandler = lazyErrorHandler

override fun onUserSet(user: User) {
syncManager.start()
Expand Down

0 comments on commit 7aa9aa6

Please sign in to comment.