Skip to content

Commit

Permalink
Improve logs of object entities
Browse files Browse the repository at this point in the history
  • Loading branch information
JcMinarro committed Aug 4, 2023
1 parent 02df882 commit 060ec41
Show file tree
Hide file tree
Showing 34 changed files with 336 additions and 104 deletions.
3 changes: 3 additions & 0 deletions stream-chat-android-client/consumer-proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@
-keep class com.squareup.moshi.JsonReader
-keep class com.squareup.moshi.JsonAdapter
-keep class kotlin.reflect.jvm.internal.* { *; }

# Rules to improve the logs by keeping the names of the classes
-keep class * extends io.getstream.chat.android.client.clientstate.UserState
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public sealed class DisconnectCause {
/**
* Happens when Web Socket connection is not available.
*/
public object WebSocketNotAvailable : DisconnectCause() { override fun toString(): String = "WSNotAvailable" }
public object WebSocketNotAvailable : DisconnectCause() {
override fun toString(): String = "WebSocketNotAvailable"
}

/**
* Happens when some non critical error occurs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ import io.getstream.chat.android.models.User as UserModel

internal sealed class UserState {
object NotSet : UserState() { override fun toString(): String = "NotSet" }
class UserSet(val user: UserModel) : UserState() { override fun toString(): String = "UserSet(id=${user.id})" }
data class UserSet(val user: UserModel) : UserState()

class AnonymousUserSet(val anonymousUser: UserModel) : UserState() {
override fun toString(): String = "AnonymousUserSet(id=${anonymousUser.id})"
}
data class AnonymousUserSet(val anonymousUser: UserModel) : UserState()

internal fun userOrError(): UserModel = when (this) {
is UserSet -> user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ internal class UserStateService {
}

private sealed class UserStateEvent {
class ConnectUser(val user: User) : UserStateEvent()
class UserUpdated(val user: User) : UserStateEvent()
class ConnectAnonymous(val user: User) : UserStateEvent()
object UnsetUser : UserStateEvent()
data class ConnectUser(val user: User) : UserStateEvent()
data class UserUpdated(val user: User) : UserStateEvent()
data class ConnectAnonymous(val user: User) : UserStateEvent()
object UnsetUser : UserStateEvent() { override fun toString(): String = "UnsetUser" }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,17 @@ internal class ChatSocketStateService(initialState: State = State.Disconnected.S
/**
* Event to notify some WebSocket event has been lost.
*/
object WebSocketEventLost : Event()
object WebSocketEventLost : Event() { override fun toString() = "WebSocketEventLost" }

/**
* Event to notify Network is not available.
*/
object NetworkNotAvailable : Event()
object NetworkNotAvailable : Event() { override fun toString() = "NetworkNotAvailable" }

/**
* Event to notify Network is available.
*/
object NetworkAvailable : Event()
object NetworkAvailable : Event() { override fun toString() = "NetworkAvailable" }

/**
* Event to notify an Unrecoverable Error happened on the WebSocket connection.
Expand All @@ -304,17 +304,17 @@ internal class ChatSocketStateService(initialState: State = State.Disconnected.S
/**
* Event to stop WebSocket connection required by user.
*/
object RequiredDisconnection : Event()
object RequiredDisconnection : Event() { override fun toString() = "RequiredDisconnection" }

/**
* Event to stop WebSocket connection.
*/
object Stop : Event()
object Stop : Event() { override fun toString() = "Stop" }

/**
* Event to resume WebSocket connection.
*/
object Resume : Event()
object Resume : Event() { override fun toString() = "Resume" }
}

internal sealed class State {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,22 @@ internal class ToggleDialogController(
}

internal sealed class ToggleState {
object Initial : ToggleState()
object Initial : ToggleState() { override fun toString(): String = "Initial" }
data class StateData(val initialToggles: Map<String, Boolean>, val changes: Map<String, Boolean>) :
ToggleState() {
fun hasChanges() = changes.isNotEmpty()
val dataSnapshot
get() = (initialToggles + changes).toList().sortedBy { it.first }
}

object Final : ToggleState()
object Final : ToggleState() { override fun toString(): String = "Final" }
}

private sealed class ToggleEvent {
class AttachView(val view: ToggleDialogFragment) : ToggleEvent()
class ToggleChanged(val toggleName: String, val value: Boolean) : ToggleEvent()
object Dismiss : ToggleEvent()
class CommitChanges(
data class AttachView(val view: ToggleDialogFragment) : ToggleEvent()
data class ToggleChanged(val toggleName: String, val value: Boolean) : ToggleEvent()
object Dismiss : ToggleEvent() { override fun toString(): String = "Dismiss" }
data class CommitChanges(
val togglesChangesCommittedListener: (changedToggles: List<Pair<String, Boolean>>) -> Unit,
) : ToggleEvent()
}
Expand Down
11 changes: 11 additions & 0 deletions stream-chat-android-compose/api/stream-chat-android-compose.api
Original file line number Diff line number Diff line change
Expand Up @@ -224,22 +224,31 @@ public final class io/getstream/chat/android/compose/state/messages/attachments/
public fun <init> ()V
public fun <init> (Ljava/util/Map;)V
public synthetic fun <init> (Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1 ()Ljava/util/Map;
public final fun copy (Ljava/util/Map;)Lio/getstream/chat/android/compose/state/messages/attachments/CustomPickerMode;
public static synthetic fun copy$default (Lio/getstream/chat/android/compose/state/messages/attachments/CustomPickerMode;Ljava/util/Map;ILjava/lang/Object;)Lio/getstream/chat/android/compose/state/messages/attachments/CustomPickerMode;
public fun equals (Ljava/lang/Object;)Z
public final fun getExtraProperties ()Ljava/util/Map;
public fun hashCode ()I
public fun toString ()Ljava/lang/String;
}

public final class io/getstream/chat/android/compose/state/messages/attachments/Files : io/getstream/chat/android/compose/state/messages/attachments/AttachmentsPickerMode {
public static final field $stable I
public static final field INSTANCE Lio/getstream/chat/android/compose/state/messages/attachments/Files;
public fun toString ()Ljava/lang/String;
}

public final class io/getstream/chat/android/compose/state/messages/attachments/Images : io/getstream/chat/android/compose/state/messages/attachments/AttachmentsPickerMode {
public static final field $stable I
public static final field INSTANCE Lio/getstream/chat/android/compose/state/messages/attachments/Images;
public fun toString ()Ljava/lang/String;
}

public final class io/getstream/chat/android/compose/state/messages/attachments/MediaCapture : io/getstream/chat/android/compose/state/messages/attachments/AttachmentsPickerMode {
public static final field $stable I
public static final field INSTANCE Lio/getstream/chat/android/compose/state/messages/attachments/MediaCapture;
public fun toString ()Ljava/lang/String;
}

public final class io/getstream/chat/android/compose/state/messages/attachments/StatefulStreamMediaRecorder {
Expand Down Expand Up @@ -1346,11 +1355,13 @@ public abstract class io/getstream/chat/android/compose/ui/messages/list/ThreadM
public final class io/getstream/chat/android/compose/ui/messages/list/ThreadMessagesStart$BOTTOM : io/getstream/chat/android/compose/ui/messages/list/ThreadMessagesStart {
public static final field $stable I
public static final field INSTANCE Lio/getstream/chat/android/compose/ui/messages/list/ThreadMessagesStart$BOTTOM;
public fun toString ()Ljava/lang/String;
}

public final class io/getstream/chat/android/compose/ui/messages/list/ThreadMessagesStart$TOP : io/getstream/chat/android/compose/ui/messages/list/ThreadMessagesStart {
public static final field $stable I
public static final field INSTANCE Lio/getstream/chat/android/compose/ui/messages/list/ThreadMessagesStart$TOP;
public fun toString ()Ljava/lang/String;
}

public final class io/getstream/chat/android/compose/ui/theme/ChatTheme {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,29 @@ import io.getstream.chat.android.models.Message
* Represents the actions the user can take with media attachments in the Media Gallery Preview
* feature.
*
* @param message The message that the action is being performed on.
* @property message The message that the action is being performed on.
*/
internal sealed class MediaGalleryPreviewAction(internal val message: Message)
internal sealed class MediaGalleryPreviewAction {
internal abstract val message: Message
}

/**
* Should take the user back to the message list with a pre-packaged
* quoted reply in the message input.
*/
internal class Reply(message: Message) : MediaGalleryPreviewAction(message)
internal data class Reply(override val message: Message) : MediaGalleryPreviewAction()

/**
* Should show the message containing the attachments in the message list.
*/
internal class ShowInChat(message: Message) : MediaGalleryPreviewAction(message)
internal data class ShowInChat(override val message: Message) : MediaGalleryPreviewAction()

/**
* Should save the media to storage.
*/
internal class SaveMedia(message: Message) : MediaGalleryPreviewAction(message)
internal data class SaveMedia(override val message: Message) : MediaGalleryPreviewAction()

/**
* Should remove the selected media attachment from the original message.
*/
internal class Delete(message: Message) : MediaGalleryPreviewAction(message)
internal data class Delete(override val message: Message) : MediaGalleryPreviewAction()
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@ public sealed class AttachmentsPickerMode
/**
* Represents the mode with media files from the device.
*/
public object Images : AttachmentsPickerMode()
public object Images : AttachmentsPickerMode() { override fun toString(): String = "Images" }

/**
* Represents the mode with files from the device.
*/
public object Files : AttachmentsPickerMode()
public object Files : AttachmentsPickerMode() { override fun toString(): String = "Files" }

/**
* Represents the mode with media capture.
*/
public object MediaCapture : AttachmentsPickerMode()
public object MediaCapture : AttachmentsPickerMode() { override fun toString(): String = "MediaCapture" }

/**
* User-customizable picker mode, with any number of extra properties.
*
* @param extraProperties Map of key-value pairs that let you store extra data for this picker mode.
*/
public class CustomPickerMode(
public data class CustomPickerMode(
public val extraProperties: Map<String, Any> = emptyMap(),
) : AttachmentsPickerMode()
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@ public sealed class ThreadMessagesStart {
/**
* Thread messages start from the top of the component.
*/
@Stable public object TOP : ThreadMessagesStart()
@Stable public object TOP : ThreadMessagesStart() {
override fun toString(): String = "TOP"
}

/**
* Thread messages start from the bottom of the component.
*/
@Stable public object BOTTOM : ThreadMessagesStart()
@Stable public object BOTTOM : ThreadMessagesStart() {
override fun toString(): String = "BOTTOM"
}
}
4 changes: 4 additions & 0 deletions stream-chat-android-core/api/stream-chat-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,7 @@ public abstract class io/getstream/chat/android/models/MessageSyncInProgress : i

public final class io/getstream/chat/android/models/MessageSyncNone : io/getstream/chat/android/models/MessageSyncContent {
public static final field INSTANCE Lio/getstream/chat/android/models/MessageSyncNone;
public fun toString ()Ljava/lang/String;
}

public final class io/getstream/chat/android/models/MessageSyncType : java/lang/Enum {
Expand Down Expand Up @@ -1181,14 +1182,17 @@ public abstract class io/getstream/chat/android/models/MessagesState {

public final class io/getstream/chat/android/models/MessagesState$Loading : io/getstream/chat/android/models/MessagesState {
public static final field INSTANCE Lio/getstream/chat/android/models/MessagesState$Loading;
public fun toString ()Ljava/lang/String;
}

public final class io/getstream/chat/android/models/MessagesState$NoQueryActive : io/getstream/chat/android/models/MessagesState {
public static final field INSTANCE Lio/getstream/chat/android/models/MessagesState$NoQueryActive;
public fun toString ()Ljava/lang/String;
}

public final class io/getstream/chat/android/models/MessagesState$OfflineNoResults : io/getstream/chat/android/models/MessagesState {
public static final field INSTANCE Lio/getstream/chat/android/models/MessagesState$OfflineNoResults;
public fun toString ()Ljava/lang/String;
}

public final class io/getstream/chat/android/models/MessagesState$Result : io/getstream/chat/android/models/MessagesState {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public sealed class MessageSyncContent
/**
* When no additional description is required to [SyncStatus].
*/
public object MessageSyncNone : MessageSyncContent()
public object MessageSyncNone : MessageSyncContent() {
override fun toString(): String = "MessageSyncNone"
}

/**
* When sync is in progress.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public sealed class MessagesState {
* The ChannelState is initialized but no query is currently running.
* If you know that a query will be started you typically want to display a loading icon.
*/
public object NoQueryActive : MessagesState()
public object NoQueryActive : MessagesState() {
override fun toString(): String = "NoQueryActive"
}

/**
* Indicates we are loading the first page of results.
Expand All @@ -35,11 +37,15 @@ public sealed class MessagesState {
* @see loadingNewerMessages
* @see loadingOlderMessages
*/
public object Loading : MessagesState()
public object Loading : MessagesState() {
override fun toString(): String = "Loading"
}

/** If we are offline and don't have channels stored in offline storage, typically displayed as an error
* condition. */
public object OfflineNoResults : MessagesState()
public object OfflineNoResults : MessagesState() {
override fun toString(): String = "OfflineNoResults"
}

/**
* The list of messages, loaded either from offline storage or an API call.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public final class io/getstream/chat/android/state/event/handler/chat/EventHandl

public final class io/getstream/chat/android/state/event/handler/chat/EventHandlingResult$Skip : io/getstream/chat/android/state/event/handler/chat/EventHandlingResult {
public static final field INSTANCE Lio/getstream/chat/android/state/event/handler/chat/EventHandlingResult$Skip;
public fun toString ()Ljava/lang/String;
}

public final class io/getstream/chat/android/state/event/handler/chat/EventHandlingResult$WatchAndAdd : io/getstream/chat/android/state/event/handler/chat/EventHandlingResult {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ public sealed class EventHandlingResult {
/**
* Skip the event.
*/
public object Skip : EventHandlingResult()
public object Skip : EventHandlingResult() {
override fun toString(): String = "Skip"
}
}

/**
Expand Down
Loading

0 comments on commit 060ec41

Please sign in to comment.