Skip to content

Commit

Permalink
chore: make objects into data objects (#2147)
Browse files Browse the repository at this point in the history
* chore: make objects into data objects

* chore: make objects into data objects
  • Loading branch information
vitorhugods authored Oct 17, 2023
1 parent 2a68af4 commit 8f461bc
Show file tree
Hide file tree
Showing 107 changed files with 242 additions and 242 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ sealed class InputAction {
val command: Command
) : InputAction()

object Quit : InputAction()
data object Quit : InputAction()
}
20 changes: 10 additions & 10 deletions cli/src/appleMain/kotlin/com/wire/kalium/cli/commands/InputFlow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ fun readChar(): Input =

sealed class Input {
data class Character(val char: Char) : Input()
object ArrowUp : Input()
object ArrowDown : Input()
object ArrowLeft : Input()
object ArrowRight : Input()
object HomeKey : Input()
object EndKey : Input()
object DeleteKey : Input()
object PageUp : Input()
object PageDown : Input()
object Backspace : Input()
data object ArrowUp : Input()
data object ArrowDown : Input()
data object ArrowLeft : Input()
data object ArrowRight : Input()
data object HomeKey : Input()
data object EndKey : Input()
data object DeleteKey : Input()
data object PageUp : Input()
data object PageDown : Input()
data object Backspace : Input()
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import platform.posix.tcsetattr
import platform.posix.termios

sealed class PosixSignal {
object WindowChanged : PosixSignal()
data object WindowChanged : PosixSignal()
}

private val signalFlow = MutableSharedFlow<PosixSignal>()
Expand Down
24 changes: 12 additions & 12 deletions logic/src/commonMain/kotlin/com/wire/kalium/logic/CoreFailure.kt
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,24 @@ sealed class NetworkFailure : CoreFailure {
/**
* Failure due to a feature not supported by the current client/backend.
*/
object FeatureNotSupported : NetworkFailure()
data object FeatureNotSupported : NetworkFailure()
}

interface MLSFailure : CoreFailure {

object WrongEpoch : MLSFailure
data object WrongEpoch : MLSFailure

object DuplicateMessage : MLSFailure
data object DuplicateMessage : MLSFailure

object BufferedFutureMessage : MLSFailure
data object BufferedFutureMessage : MLSFailure

object SelfCommitIgnored : MLSFailure
data object SelfCommitIgnored : MLSFailure

object UnmergedPendingGroup : MLSFailure
data object UnmergedPendingGroup : MLSFailure

object ConversationAlreadyExists : MLSFailure
data object ConversationAlreadyExists : MLSFailure

object ConversationDoesNotSupportMLS : MLSFailure
data object ConversationDoesNotSupportMLS : MLSFailure

class Generic(internal val exception: Exception) : MLSFailure {
val rootCause: Throwable get() = exception
Expand All @@ -199,13 +199,13 @@ class ProteusFailure(internal val proteusException: ProteusException) : CoreFail
}

sealed class EncryptionFailure : CoreFailure.FeatureFailure() {
object GenericEncryptionError : EncryptionFailure()
object GenericDecryptionError : EncryptionFailure()
object WrongAssetHash : EncryptionFailure()
data object GenericEncryptionError : EncryptionFailure()
data object GenericDecryptionError : EncryptionFailure()
data object WrongAssetHash : EncryptionFailure()
}

sealed class StorageFailure : CoreFailure {
object DataNotFound : StorageFailure()
data object DataNotFound : StorageFailure()
data class Generic(val rootCause: Throwable) : StorageFailure()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ data class FileSharingStatus(
val isStatusChanged: Boolean?
) {
sealed interface Value {
object Disabled : Value
object EnabledAll : Value
data object Disabled : Value
data object EnabledAll : Value
data class EnabledSome(val allowedType: List<String>) : Value
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ data class Conversation(
get() = type in setOf(Type.ONE_ON_ONE, Type.GROUP)

sealed interface ProtocolInfo {
object Proteus : ProtocolInfo {
data object Proteus : ProtocolInfo {
override fun name() = "Proteus"
}

Expand Down Expand Up @@ -247,8 +247,8 @@ data class Conversation(

data class Member(val id: UserId, val role: Role) {
sealed class Role {
object Member : Role()
object Admin : Role()
data object Member : Role()
data object Admin : Role()
data class Unknown(val name: String) : Role()

override fun toString(): String =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ sealed class MutedConversationStatus(open val status: Int = 0) {
/**
* 0 -> All notifications are displayed
*/
object AllAllowed : MutedConversationStatus(0)
data object AllAllowed : MutedConversationStatus(0)

/**
* 1 -> Only mentions and replies are displayed (normal messages muted)
*/
object OnlyMentionsAndRepliesAllowed : MutedConversationStatus(1)
data object OnlyMentionsAndRepliesAllowed : MutedConversationStatus(1)

/**
* 3 -> No notifications are displayed
*/
object AllMuted : MutedConversationStatus(3)
data object AllMuted : MutedConversationStatus(3)
}
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ sealed interface Message {
}

sealed class EditStatus {
object NotEdited : EditStatus()
data object NotEdited : EditStatus()
data class Edited(val lastTimeStamp: String) : EditStatus()

override fun toString(): String = when (this) {
Expand Down Expand Up @@ -438,7 +438,7 @@ sealed interface Message {
) {

sealed class SelfDeletionStatus {
object NotStarted : SelfDeletionStatus()
data object NotStarted : SelfDeletionStatus()

data class Started(val selfDeletionStartDate: Instant) : SelfDeletionStatus()

Expand Down Expand Up @@ -599,7 +599,7 @@ sealed class DeliveryStatus {
val recipientsFailedDelivery: List<UserId>
) : DeliveryStatus()

object CompleteDelivery : DeliveryStatus()
data object CompleteDelivery : DeliveryStatus()

fun toLogMap(): Map<String, String> = when (this) {
is PartialDelivery -> mutableMapOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ sealed class MessageContent {
val assetMimeType: String
) : Content

object Deleted : Content
data object Deleted : Content

object Invalid : Content
data object Invalid : Content
}

data class Asset(val value: AssetContent) : Regular()
Expand Down Expand Up @@ -245,7 +245,7 @@ sealed class MessageContent {

data class TeamMemberRemoved(val userName: String) : System()

object MissedCall : System()
data object MissedCall : System()

data class Reaction(
val messageId: String,
Expand Down Expand Up @@ -279,7 +279,7 @@ sealed class MessageContent {
) : System()

// we can add other types to be processed, but signaling ones shouldn't be persisted
object Ignored : Signaling() // messages that aren't processed in any way
data object Ignored : Signaling() // messages that aren't processed in any way

data class FailedDecryption(
val encodedData: ByteArray? = null,
Expand All @@ -288,16 +288,16 @@ sealed class MessageContent {
val clientId: ClientId? = null
) : Regular()

object MLSWrongEpochWarning : System()
data object MLSWrongEpochWarning : System()

object ClientAction : Signaling()
data object ClientAction : Signaling()

object CryptoSessionReset : System()
data object CryptoSessionReset : System()

object HistoryLostProtocolChanged : System()
data object HistoryLostProtocolChanged : System()

object HistoryLost : System()
object ConversationCreated : System()
data object HistoryLost : System()
data object ConversationCreated : System()
data object ConversationDegradedMLS : System()
data object ConversationVerifiedMLS : System()
data object ConversationDegradedProteus : System()
Expand Down Expand Up @@ -420,8 +420,8 @@ sealed interface MessagePreviewContent {
val otherUserIdList: List<UserId>
) : MessagePreviewContent

object CryptoSessionReset : MessagePreviewContent
data object CryptoSessionReset : MessagePreviewContent

object Unknown : MessagePreviewContent
data object Unknown : MessagePreviewContent

}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ data class SearchUsersOptions(
}

sealed class ConversationMemberExcludedOptions {
object None : ConversationMemberExcludedOptions()
data object None : ConversationMemberExcludedOptions()
data class ConversationExcluded(val conversationId: QualifiedID) : ConversationMemberExcludedOptions()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import com.wire.kalium.logic.CoreFailure

sealed interface IncrementalSyncStatus {

object Pending : IncrementalSyncStatus {
data object Pending : IncrementalSyncStatus {
override fun toString(): String = "PENDING"
}

object FetchingPendingEvents : IncrementalSyncStatus {
data object FetchingPendingEvents : IncrementalSyncStatus {
override fun toString() = "FETCHING_PENDING_EVENTS"
}

object Live : IncrementalSyncStatus {
data object Live : IncrementalSyncStatus {
override fun toString() = "LIVE"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import com.wire.kalium.logic.CoreFailure

sealed interface SlowSyncStatus {

object Pending : SlowSyncStatus
data object Pending : SlowSyncStatus

object Complete : SlowSyncStatus
data object Complete : SlowSyncStatus

data class Ongoing(val currentStep: SlowSyncStep) : SlowSyncStatus

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ sealed class SyncState {
/**
* Sync hasn't started yet.
*/
object Waiting : SyncState()
data object Waiting : SyncState()

/**
* Fetching all initial data:
Expand All @@ -37,19 +37,19 @@ sealed class SyncState {
* - All team members (if user belongs to a team)
* - Details of all other users discovered in past steps
*/
object SlowSync : SyncState()
data object SlowSync : SyncState()

/**
* Is fetching events lost while this client was offline.
* Implies that [SlowSync] is done.
*/
object GatheringPendingEvents : SyncState()
data object GatheringPendingEvents : SyncState()

/**
* Is processing events, connected to the server and receiving real-time events.
* This implies that [GatheringPendingEvents] is done.
*/
object Live : SyncState()
data object Live : SyncState()

/**
* Sync was not completed due to a failure.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ sealed class WebEventContent {

@Serializable
@SerialName("unknown")
object Unknown : WebEventContent()
data object Unknown : WebEventContent()
}

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ package com.wire.kalium.logic.failure
import com.wire.kalium.logic.CoreFailure

sealed class ServerConfigFailure : CoreFailure.FeatureFailure() {
object UnknownServerVersion : ServerConfigFailure()
object NewServerVersion : ServerConfigFailure()
data object UnknownServerVersion : ServerConfigFailure()
data object NewServerVersion : ServerConfigFailure()
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ class UpdateAssetMessageDownloadStatusUseCaseImpl(
}

sealed class UpdateDownloadStatusResult {
object Success : UpdateDownloadStatusResult()
data object Success : UpdateDownloadStatusResult()
data class Failure(val coreFailure: CoreFailure) : UpdateDownloadStatusResult()
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ internal class UpdateAssetMessageUploadStatusUseCaseImpl(
}

sealed class UpdateUploadStatusResult {
object Success : UpdateUploadStatusResult()
data object Success : UpdateUploadStatusResult()
data class Failure(val coreFailure: CoreFailure) : UpdateUploadStatusResult()
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AddAuthenticatedUserUseCase internal constructor(
sealed class Result {
data class Success(val userId: UserId) : Result()
sealed class Failure : Result() {
object UserAlreadyExists : Failure()
data object UserAlreadyExists : Failure()
data class Generic(val genericFailure: CoreFailure) : Failure()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@ sealed class AuthenticationResult {
) : AuthenticationResult()

sealed class Failure : AuthenticationResult() {
object SocketError : Failure()
data object SocketError : Failure()
sealed class InvalidCredentials : Failure() {
/**
* The team has enabled 2FA but the user has not entered it yet
*/
object Missing2FA : InvalidCredentials()
data object Missing2FA : InvalidCredentials()

/**
* The user has entered an invalid 2FA code, or the 2FA code has expired
*/
object Invalid2FA : InvalidCredentials()
data object Invalid2FA : InvalidCredentials()

/**
* The user has entered an invalid email/handle or password combination
*/
object InvalidPasswordIdentityCombination : InvalidCredentials()
data object InvalidPasswordIdentityCombination : InvalidCredentials()
}

/**
* The user has entered a text that isn't considered a valid email or handle
*/
object InvalidUserIdentifier : Failure()
data object InvalidUserIdentifier : Failure()
data class Generic(val genericFailure: CoreFailure) : Failure()
}
}
Expand Down
Loading

0 comments on commit 8f461bc

Please sign in to comment.