Merge pull request #5503 from element-hq/feature/bma/immutableCleanup
Do some cleanup on our immutable annotation usage
This commit is contained in:
33
.github/workflows/quality.yml
vendored
33
.github/workflows/quality.yml
vendored
@@ -103,6 +103,39 @@ jobs:
|
||||
path: |
|
||||
**/build/reports/**/*.*
|
||||
|
||||
compose:
|
||||
name: Compose tests
|
||||
runs-on: ubuntu-latest
|
||||
# Allow all jobs on main and develop. Just one per PR.
|
||||
concurrency:
|
||||
group: ${{ github.ref == 'refs/heads/main' && format('check-compose-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('check-compose-develop-{0}', github.sha) || format('check-compose-{0}', github.ref) }}
|
||||
cancel-in-progress: true
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
with:
|
||||
# Ensure we are building the branch and not the branch after being merged on develop
|
||||
# https://github.com/actions/checkout/issues/881
|
||||
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref }}
|
||||
- name: Add SSH private keys for submodule repositories
|
||||
uses: webfactory/ssh-agent@a6f90b1f127823b31d4d4a8d96047790581349bd # v0.9.1
|
||||
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'element-hq/element-x-android' }}
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.ELEMENT_ENTERPRISE_DEPLOY_KEY }}
|
||||
- name: Clone submodules
|
||||
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == 'element-hq/element-x-android' }}
|
||||
run: git submodule update --init --recursive
|
||||
- name: Use JDK 21
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: 'temurin' # See 'Supported distributions' for available options
|
||||
java-version: '21'
|
||||
- name: Configure gradle
|
||||
uses: gradle/actions/setup-gradle@v5
|
||||
with:
|
||||
cache-read-only: ${{ github.ref != 'refs/heads/develop' }}
|
||||
- name: Run compose tests
|
||||
run: ./tools/compose/check_stability.sh
|
||||
|
||||
lint:
|
||||
name: Android lint check
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -7,12 +7,10 @@
|
||||
|
||||
package io.element.android.appnav.root
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.features.rageshake.api.crash.CrashDetectionState
|
||||
import io.element.android.features.rageshake.api.detection.RageshakeDetectionState
|
||||
import io.element.android.services.apperror.api.AppErrorState
|
||||
|
||||
@Immutable
|
||||
data class RootState(
|
||||
val rageshakeDetectionState: RageshakeDetectionState,
|
||||
val crashDetectionState: CrashDetectionState,
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
package io.element.android.features.createroom.impl.configureroom
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
||||
// Annotate with @Immutable since `Uri` is unstable
|
||||
@Immutable
|
||||
data class CreateRoomConfig(
|
||||
val roomName: String? = null,
|
||||
val topic: String? = null,
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package io.element.android.features.home.impl
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.features.home.impl.roomlist.RoomListState
|
||||
import io.element.android.features.home.impl.spaces.HomeSpacesState
|
||||
import io.element.android.features.logout.api.direct.DirectLogoutState
|
||||
@@ -15,7 +14,6 @@ import io.element.android.libraries.designsystem.utils.snackbar.SnackbarMessage
|
||||
import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
@Immutable
|
||||
data class HomeState(
|
||||
/**
|
||||
* The current user of this session, in case of multiple accounts, will contains 3 items, with the
|
||||
|
||||
@@ -19,7 +19,6 @@ import io.element.android.libraries.push.api.battery.BatteryOptimizationState
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.ImmutableSet
|
||||
|
||||
@Immutable
|
||||
data class RoomListState(
|
||||
val contextMenu: ContextMenu,
|
||||
val declineInviteMenu: DeclineInviteMenu,
|
||||
|
||||
@@ -16,7 +16,9 @@ import io.element.android.features.invite.api.SeenInvitesStore
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import io.element.android.libraries.matrix.api.MatrixClient
|
||||
import io.element.android.libraries.matrix.ui.safety.rememberHideInvitesAvatar
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.persistentSetOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableSet
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
||||
@@ -28,7 +30,10 @@ class HomeSpacesPresenter(
|
||||
@Composable
|
||||
override fun present(): HomeSpacesState {
|
||||
val hideInvitesAvatar by client.rememberHideInvitesAvatar()
|
||||
val spaceRooms by client.spaceService.spaceRoomsFlow.collectAsState(emptyList())
|
||||
val spaceRooms by remember {
|
||||
client.spaceService.spaceRoomsFlow.map { it.toImmutableList() }
|
||||
}.collectAsState(persistentListOf())
|
||||
|
||||
val seenSpaceInvites by remember {
|
||||
seenInvitesStore.seenRoomIds().map { it.toImmutableSet() }
|
||||
}.collectAsState(persistentSetOf())
|
||||
|
||||
@@ -9,11 +9,12 @@ package io.element.android.features.home.impl.spaces
|
||||
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.spaces.SpaceRoom
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.ImmutableSet
|
||||
|
||||
data class HomeSpacesState(
|
||||
val space: CurrentSpace,
|
||||
val spaceRooms: List<SpaceRoom>,
|
||||
val spaceRooms: ImmutableList<SpaceRoom>,
|
||||
val seenSpaceInvites: ImmutableSet<RoomId>,
|
||||
val hideInvitesAvatar: Boolean,
|
||||
val eventSink: (HomeSpacesEvents) -> Unit,
|
||||
|
||||
@@ -11,6 +11,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.spaces.SpaceRoom
|
||||
import io.element.android.libraries.previewutils.room.aSpaceRoom
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableSet
|
||||
|
||||
open class HomeSpacesStateProvider : PreviewParameterProvider<HomeSpacesState> {
|
||||
@@ -39,7 +40,7 @@ internal fun aHomeSpacesState(
|
||||
eventSink: (HomeSpacesEvents) -> Unit = {},
|
||||
) = HomeSpacesState(
|
||||
space = space,
|
||||
spaceRooms = spaceRooms,
|
||||
spaceRooms = spaceRooms.toImmutableList(),
|
||||
seenSpaceInvites = seenSpaceInvites.toImmutableSet(),
|
||||
hideInvitesAvatar = hideInvitesAvatar,
|
||||
eventSink = eventSink,
|
||||
|
||||
@@ -24,7 +24,6 @@ import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
internal const val MAX_KNOCK_MESSAGE_LENGTH = 500
|
||||
|
||||
@Immutable
|
||||
data class JoinRoomState(
|
||||
val roomIdOrAlias: RoomIdOrAlias,
|
||||
val contentState: ContentState,
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
package io.element.android.features.leaveroom.api
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
|
||||
@Immutable
|
||||
interface LeaveRoomState {
|
||||
val eventSink: (LeaveRoomEvent) -> Unit
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import io.element.android.features.login.impl.accountprovider.AccountProvider
|
||||
import io.element.android.features.login.impl.changeserver.ChangeServerState
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import io.element.android.libraries.core.uri.ensureProtocol
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
@Inject
|
||||
class ChangeAccountProviderPresenter(
|
||||
@@ -39,6 +40,7 @@ class ChangeAccountProviderPresenter(
|
||||
isValid = true,
|
||||
)
|
||||
}
|
||||
.toImmutableList()
|
||||
}
|
||||
|
||||
val canSearchForAccountProviders = remember {
|
||||
|
||||
@@ -9,10 +9,11 @@ package io.element.android.features.login.impl.screens.changeaccountprovider
|
||||
|
||||
import io.element.android.features.login.impl.accountprovider.AccountProvider
|
||||
import io.element.android.features.login.impl.changeserver.ChangeServerState
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
// Do not use default value, so no member get forgotten in the presenters.
|
||||
data class ChangeAccountProviderState(
|
||||
val accountProviders: List<AccountProvider>,
|
||||
val accountProviders: ImmutableList<AccountProvider>,
|
||||
val canSearchForAccountProviders: Boolean,
|
||||
val changeServerState: ChangeServerState,
|
||||
)
|
||||
|
||||
@@ -12,6 +12,7 @@ import io.element.android.features.login.impl.accountprovider.AccountProvider
|
||||
import io.element.android.features.login.impl.accountprovider.anAccountProvider
|
||||
import io.element.android.features.login.impl.changeserver.ChangeServerState
|
||||
import io.element.android.features.login.impl.changeserver.aChangeServerState
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
open class ChangeAccountProviderStateProvider : PreviewParameterProvider<ChangeAccountProviderState> {
|
||||
override val values: Sequence<ChangeAccountProviderState>
|
||||
@@ -29,7 +30,7 @@ fun aChangeAccountProviderState(
|
||||
canSearchForAccountProviders: Boolean = true,
|
||||
changeServerState: ChangeServerState = aChangeServerState(),
|
||||
) = ChangeAccountProviderState(
|
||||
accountProviders = accountProviders,
|
||||
accountProviders = accountProviders.toImmutableList(),
|
||||
canSearchForAccountProviders = canSearchForAccountProviders,
|
||||
changeServerState = changeServerState,
|
||||
)
|
||||
|
||||
@@ -21,6 +21,7 @@ import io.element.android.features.login.impl.login.LoginHelper
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import io.element.android.libraries.core.uri.ensureProtocol
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
@Inject
|
||||
class ChooseAccountProviderPresenter(
|
||||
@@ -69,6 +70,7 @@ class ChooseAccountProviderPresenter(
|
||||
isValid = true,
|
||||
)
|
||||
}
|
||||
.toImmutableList()
|
||||
}
|
||||
|
||||
return ChooseAccountProviderState(
|
||||
|
||||
@@ -10,10 +10,11 @@ package io.element.android.features.login.impl.screens.chooseaccountprovider
|
||||
import io.element.android.features.login.impl.accountprovider.AccountProvider
|
||||
import io.element.android.features.login.impl.login.LoginMode
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
// Do not use default value, so no member get forgotten in the presenters.
|
||||
data class ChooseAccountProviderState(
|
||||
val accountProviders: List<AccountProvider>,
|
||||
val accountProviders: ImmutableList<AccountProvider>,
|
||||
val selectedAccountProvider: AccountProvider?,
|
||||
val loginMode: AsyncData<LoginMode>,
|
||||
val eventSink: (ChooseAccountProviderEvents) -> Unit,
|
||||
|
||||
@@ -12,6 +12,7 @@ import io.element.android.features.login.impl.accountprovider.AccountProvider
|
||||
import io.element.android.features.login.impl.accountprovider.anAccountProvider
|
||||
import io.element.android.features.login.impl.login.LoginMode
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
open class ChooseAccountProviderStateProvider : PreviewParameterProvider<ChooseAccountProviderState> {
|
||||
private val server1 = anAccountProvider(
|
||||
@@ -70,7 +71,7 @@ fun aChooseAccountProviderState(
|
||||
loginMode: AsyncData<LoginMode> = AsyncData.Uninitialized,
|
||||
eventSink: (ChooseAccountProviderEvents) -> Unit = {},
|
||||
) = ChooseAccountProviderState(
|
||||
accountProviders = accountProviders,
|
||||
accountProviders = accountProviders.toImmutableList(),
|
||||
selectedAccountProvider = selectedAccountProvider,
|
||||
loginMode = loginMode,
|
||||
eventSink = eventSink,
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package io.element.android.features.messages.impl
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.features.messages.api.timeline.voicemessages.composer.VoiceMessageComposerState
|
||||
import io.element.android.features.messages.impl.actionlist.ActionListState
|
||||
import io.element.android.features.messages.impl.crypto.identity.IdentityChangeState
|
||||
@@ -29,7 +28,6 @@ import io.element.android.libraries.matrix.api.encryption.identity.IdentityState
|
||||
import io.element.android.libraries.matrix.api.room.tombstone.SuccessorRoom
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
@Immutable
|
||||
data class MessagesState(
|
||||
val roomId: RoomId,
|
||||
val roomName: String?,
|
||||
|
||||
@@ -13,7 +13,6 @@ import io.element.android.features.messages.impl.crypto.sendfailure.VerifiedUser
|
||||
import io.element.android.features.messages.impl.timeline.model.TimelineItem
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
@Immutable
|
||||
data class ActionListState(
|
||||
val target: Target,
|
||||
val eventSink: (ActionListEvents) -> Unit,
|
||||
|
||||
@@ -9,11 +9,9 @@ package io.element.android.features.messages.impl.actionlist.model
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.designsystem.icons.CompoundDrawables
|
||||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
|
||||
@Immutable
|
||||
enum class TimelineItemAction(
|
||||
@StringRes val titleRes: Int,
|
||||
@DrawableRes val icon: Int,
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
|
||||
package io.element.android.features.messages.impl.attachments.preview
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
|
||||
@Immutable
|
||||
sealed interface AttachmentsPreviewEvents {
|
||||
data object SendAttachment : AttachmentsPreviewEvents
|
||||
data object CancelAndDismiss : AttachmentsPreviewEvents
|
||||
|
||||
@@ -8,12 +8,10 @@
|
||||
package io.element.android.features.messages.impl.messagecomposer
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.textcomposer.mentions.ResolvedSuggestion
|
||||
import io.element.android.libraries.textcomposer.model.MessageComposerMode
|
||||
import io.element.android.libraries.textcomposer.model.Suggestion
|
||||
|
||||
@Immutable
|
||||
sealed interface MessageComposerEvents {
|
||||
data object ToggleFullScreenState : MessageComposerEvents
|
||||
data object SendMessage : MessageComposerEvents
|
||||
@@ -30,6 +28,7 @@ sealed interface MessageComposerEvents {
|
||||
data object Location : PickAttachmentSource
|
||||
data object Poll : PickAttachmentSource
|
||||
}
|
||||
|
||||
data class ToggleTextFormatting(val enabled: Boolean) : MessageComposerEvents
|
||||
data class Error(val error: Throwable) : MessageComposerEvents
|
||||
data class TypingNotice(val isTyping: Boolean) : MessageComposerEvents
|
||||
|
||||
@@ -105,7 +105,7 @@ class PinnedMessagesListPresenter(
|
||||
// We do not care about the call state here.
|
||||
roomCallState = aStandByCallState(),
|
||||
// don't compute this value or the pin icon will be shown
|
||||
pinnedEventIds = emptyList(),
|
||||
pinnedEventIds = persistentListOf(),
|
||||
typingNotificationState = TypingNotificationState(
|
||||
renderTypingNotifications = false,
|
||||
typingMembers = persistentListOf(),
|
||||
|
||||
@@ -21,7 +21,6 @@ import io.element.android.libraries.matrix.api.timeline.item.event.MessageShield
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlin.time.Duration
|
||||
|
||||
@Immutable
|
||||
data class TimelineState(
|
||||
val timelineItems: ImmutableList<TimelineItem>,
|
||||
val timelineRoomInfo: TimelineRoomInfo,
|
||||
@@ -72,14 +71,13 @@ sealed interface FocusRequestState {
|
||||
}
|
||||
}
|
||||
|
||||
@Immutable
|
||||
data class TimelineRoomInfo(
|
||||
val isDm: Boolean,
|
||||
val name: String?,
|
||||
val userHasPermissionToSendMessage: Boolean,
|
||||
val userHasPermissionToSendReaction: Boolean,
|
||||
val roomCallState: RoomCallState,
|
||||
val pinnedEventIds: List<EventId>,
|
||||
val pinnedEventIds: ImmutableList<EventId>,
|
||||
val typingNotificationState: TypingNotificationState,
|
||||
val predecessorRoom: PredecessorRoom?,
|
||||
)
|
||||
|
||||
@@ -259,7 +259,7 @@ internal fun aTimelineRoomInfo(
|
||||
userHasPermissionToSendMessage = userHasPermissionToSendMessage,
|
||||
userHasPermissionToSendReaction = true,
|
||||
roomCallState = aStandByCallState(),
|
||||
pinnedEventIds = pinnedEventIds,
|
||||
pinnedEventIds = pinnedEventIds.toImmutableList(),
|
||||
typingNotificationState = typingNotificationState,
|
||||
predecessorRoom = predecessorRoom,
|
||||
)
|
||||
|
||||
@@ -8,11 +8,14 @@
|
||||
package io.element.android.features.messages.impl.timeline.components.customreaction.picker
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.emojibasebindings.Emoji
|
||||
import io.element.android.libraries.designsystem.theme.components.IconSource
|
||||
import io.element.android.libraries.designsystem.theme.components.SearchBarResultState
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
// Emoji is unstable (because from an external library?), so we annotate with @Immutable
|
||||
@Immutable
|
||||
data class EmojiPickerState(
|
||||
val categories: ImmutableList<EmojiCategory>,
|
||||
val allEmojis: ImmutableList<Emoji>,
|
||||
|
||||
@@ -7,10 +7,8 @@
|
||||
|
||||
package io.element.android.features.messages.impl.timeline.components.receipt.bottomsheet
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.features.messages.impl.timeline.model.TimelineItem
|
||||
|
||||
@Immutable
|
||||
data class ReadReceiptBottomSheetState(
|
||||
val selectedEvent: TimelineItem.Event?,
|
||||
val eventSink: (ReadReceiptBottomSheetEvents) -> Unit,
|
||||
|
||||
@@ -21,7 +21,6 @@ import io.element.android.features.messages.impl.timeline.model.TimelineItemReac
|
||||
import io.element.android.features.messages.impl.timeline.model.TimelineItemReadReceipts
|
||||
import io.element.android.features.messages.impl.timeline.model.TimelineItemThreadInfo
|
||||
import io.element.android.features.messages.impl.utils.messagesummary.MessageSummaryFormatter
|
||||
import io.element.android.libraries.architecture.map
|
||||
import io.element.android.libraries.core.bool.orTrue
|
||||
import io.element.android.libraries.dateformatter.api.DateFormatter
|
||||
import io.element.android.libraries.dateformatter.api.DateFormatterMode
|
||||
@@ -37,7 +36,6 @@ import io.element.android.libraries.matrix.api.timeline.item.event.getDisambigua
|
||||
import io.element.android.libraries.matrix.ui.messages.reply.map
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import java.util.Date
|
||||
|
||||
@AssistedInject
|
||||
class TimelineItemEventFactory(
|
||||
@@ -146,10 +144,9 @@ class TimelineItemEventFactory(
|
||||
senders = reaction.senders
|
||||
.sortedByDescending { it.timestamp }
|
||||
.map {
|
||||
val date = Date(it.timestamp)
|
||||
AggregatedReactionSender(
|
||||
senderId = it.senderId,
|
||||
timestamp = date,
|
||||
timestamp = it.timestamp,
|
||||
sentTime = dateFormatter.format(
|
||||
it.timestamp,
|
||||
DateFormatterMode.TimeOrDate,
|
||||
|
||||
@@ -33,13 +33,14 @@ fun anAggregatedReaction(
|
||||
val timeFormatter = DateFormat.getTimeInstance(DateFormat.SHORT, java.util.Locale.US).apply {
|
||||
timeZone = TimeZone.getTimeZone("UTC")
|
||||
}
|
||||
val date = Date(1_689_061_264L)
|
||||
val timestamp = 1_689_061_264L
|
||||
val date = Date(timestamp)
|
||||
val senders = buildList {
|
||||
repeat(count) { index ->
|
||||
add(
|
||||
AggregatedReactionSender(
|
||||
senderId = if (isHighlighted && index == 0) userId else UserId("@user$index:server.org"),
|
||||
timestamp = date,
|
||||
timestamp = timestamp,
|
||||
sentTime = timeFormatter.format(date),
|
||||
)
|
||||
)
|
||||
|
||||
@@ -7,15 +7,12 @@
|
||||
|
||||
package io.element.android.features.messages.impl.timeline.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||
import java.util.Date
|
||||
|
||||
@Immutable
|
||||
data class AggregatedReactionSender(
|
||||
val senderId: UserId,
|
||||
val timestamp: Date,
|
||||
val timestamp: Long,
|
||||
val sentTime: String,
|
||||
val user: MatrixUser? = null
|
||||
)
|
||||
|
||||
@@ -57,13 +57,11 @@ sealed interface TimelineItem {
|
||||
is GroupedEvents -> "groupedEvent"
|
||||
}
|
||||
|
||||
@Immutable
|
||||
data class Virtual(
|
||||
val id: UniqueId,
|
||||
val model: TimelineItemVirtualModel
|
||||
) : TimelineItem
|
||||
|
||||
@Immutable
|
||||
data class Event(
|
||||
val id: UniqueId,
|
||||
// Note: eventId can be null when the event is a local echo
|
||||
@@ -124,7 +122,6 @@ sealed interface TimelineItem {
|
||||
val sendhandle: SendHandle? get() = sendHandleProvider()
|
||||
}
|
||||
|
||||
@Immutable
|
||||
data class GroupedEvents(
|
||||
val id: UniqueId,
|
||||
val events: ImmutableList<Event>,
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
package io.element.android.features.preferences.impl.about
|
||||
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
data class AboutState(
|
||||
val elementLegals: List<ElementLegal>,
|
||||
val elementLegals: ImmutableList<ElementLegal>,
|
||||
)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
package io.element.android.features.preferences.impl.about
|
||||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
open class AboutStateProvider : PreviewParameterProvider<AboutState> {
|
||||
override val values: Sequence<AboutState>
|
||||
@@ -19,5 +20,5 @@ open class AboutStateProvider : PreviewParameterProvider<AboutState> {
|
||||
fun anAboutState(
|
||||
elementLegals: List<ElementLegal> = getAllLegals(),
|
||||
) = AboutState(
|
||||
elementLegals = elementLegals,
|
||||
elementLegals = elementLegals.toImmutableList(),
|
||||
)
|
||||
|
||||
@@ -10,6 +10,8 @@ package io.element.android.features.preferences.impl.about
|
||||
import androidx.annotation.StringRes
|
||||
import io.element.android.features.preferences.impl.BuildConfig
|
||||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
||||
private const val COPYRIGHT_URL = BuildConfig.URL_COPYRIGHT
|
||||
private const val USE_POLICY_URL = BuildConfig.URL_ACCEPTABLE_USE
|
||||
@@ -24,8 +26,8 @@ sealed class ElementLegal(
|
||||
data object PrivacyPolicy : ElementLegal(CommonStrings.common_privacy_policy, PRIVACY_URL)
|
||||
}
|
||||
|
||||
fun getAllLegals(): List<ElementLegal> {
|
||||
return listOf(
|
||||
fun getAllLegals(): ImmutableList<ElementLegal> {
|
||||
return persistentListOf(
|
||||
ElementLegal.Copyright,
|
||||
ElementLegal.AcceptableUsePolicy,
|
||||
ElementLegal.PrivacyPolicy,
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package io.element.android.features.preferences.impl.notifications
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.architecture.AsyncAction
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.fullscreenintent.api.FullScreenIntentPermissionsState
|
||||
@@ -15,7 +14,6 @@ import io.element.android.libraries.matrix.api.room.RoomNotificationMode
|
||||
import io.element.android.libraries.pushproviders.api.Distributor
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
@Immutable
|
||||
data class NotificationSettingsState(
|
||||
val matrixSettings: MatrixSettings,
|
||||
val appSettings: AppSettings,
|
||||
|
||||
@@ -8,12 +8,15 @@
|
||||
package io.element.android.features.preferences.impl.user.editprofile
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.architecture.AsyncAction
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
import io.element.android.libraries.matrix.ui.media.AvatarAction
|
||||
import io.element.android.libraries.permissions.api.PermissionsState
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
// Annotate with @Immutable since `Uri` is unstable
|
||||
@Immutable
|
||||
data class EditUserProfileState(
|
||||
val userId: UserId,
|
||||
val displayName: String,
|
||||
|
||||
@@ -7,9 +7,6 @@
|
||||
|
||||
package io.element.android.features.rageshake.api.crash
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
|
||||
@Immutable
|
||||
data class CrashDetectionState(
|
||||
val appName: String,
|
||||
val crashDetected: Boolean,
|
||||
|
||||
@@ -7,10 +7,8 @@
|
||||
|
||||
package io.element.android.features.rageshake.api.detection
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.features.rageshake.api.preferences.RageshakePreferencesState
|
||||
|
||||
@Immutable
|
||||
data class RageshakeDetectionState(
|
||||
val takeScreenshot: Boolean,
|
||||
val showDialog: Boolean,
|
||||
|
||||
@@ -7,12 +7,10 @@
|
||||
|
||||
package io.element.android.features.roomaliasresolver.impl
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.matrix.api.core.RoomAlias
|
||||
import io.element.android.libraries.matrix.api.room.alias.ResolvedRoomAlias
|
||||
|
||||
@Immutable
|
||||
data class RoomAliasResolverState(
|
||||
val roomAlias: RoomAlias,
|
||||
val resolveState: AsyncData<ResolvedRoomAlias>,
|
||||
|
||||
@@ -8,12 +8,15 @@
|
||||
package io.element.android.features.roomdetails.impl.edit
|
||||
|
||||
import android.net.Uri
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.architecture.AsyncAction
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.ui.media.AvatarAction
|
||||
import io.element.android.libraries.permissions.api.PermissionsState
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
// Annotate with @Immutable since `Uri` is unstable
|
||||
@Immutable
|
||||
data class RoomDetailsEditState(
|
||||
val roomId: RoomId,
|
||||
/** The raw room name (i.e. the room name from the state event `m.room.name`), not the display name. */
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id("io.element.android-library")
|
||||
id("io.element.android-compose-library")
|
||||
id("kotlin-parcelize")
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
package io.element.android.features.roomdirectory.api
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.designsystem.components.avatar.AvatarData
|
||||
import io.element.android.libraries.designsystem.components.avatar.AvatarSize
|
||||
import io.element.android.libraries.matrix.api.core.RoomAlias
|
||||
@@ -17,7 +16,6 @@ import kotlinx.parcelize.IgnoredOnParcel
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Parcelize
|
||||
@Immutable
|
||||
data class RoomDescription(
|
||||
val roomId: RoomId,
|
||||
val name: String?,
|
||||
|
||||
@@ -42,14 +42,14 @@ class RoomDirectoryPresenterTest {
|
||||
|
||||
@Test
|
||||
fun `present - room directory list emits empty state`() = runTest {
|
||||
val directoryListStateFlow = MutableSharedFlow<RoomDirectoryList.State>(replay = 1)
|
||||
val directoryListStateFlow = MutableSharedFlow<RoomDirectoryList.SearchResult>(replay = 1)
|
||||
val roomDirectoryList = FakeRoomDirectoryList(directoryListStateFlow)
|
||||
val roomDirectoryService = FakeRoomDirectoryService { roomDirectoryList }
|
||||
val presenter = createRoomDirectoryPresenter(roomDirectoryService = roomDirectoryService)
|
||||
presenter.test {
|
||||
skipItems(1)
|
||||
directoryListStateFlow.emit(
|
||||
RoomDirectoryList.State(false, emptyList())
|
||||
RoomDirectoryList.SearchResult(false, emptyList())
|
||||
)
|
||||
awaitItem().also { state ->
|
||||
assertThat(state.displayEmptyState).isTrue()
|
||||
@@ -60,14 +60,14 @@ class RoomDirectoryPresenterTest {
|
||||
|
||||
@Test
|
||||
fun `present - room directory list emits non-empty state`() = runTest {
|
||||
val directoryListStateFlow = MutableSharedFlow<RoomDirectoryList.State>(replay = 1)
|
||||
val directoryListStateFlow = MutableSharedFlow<RoomDirectoryList.SearchResult>(replay = 1)
|
||||
val roomDirectoryList = FakeRoomDirectoryList(directoryListStateFlow)
|
||||
val roomDirectoryService = FakeRoomDirectoryService { roomDirectoryList }
|
||||
val presenter = createRoomDirectoryPresenter(roomDirectoryService = roomDirectoryService)
|
||||
presenter.test {
|
||||
skipItems(1)
|
||||
directoryListStateFlow.emit(
|
||||
RoomDirectoryList.State(
|
||||
RoomDirectoryList.SearchResult(
|
||||
hasMoreToLoad = true,
|
||||
items = listOf(aRoomDescription())
|
||||
)
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
package io.element.android.features.roommembermoderation.api
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
|
||||
@Immutable
|
||||
interface RoomMemberModerationState {
|
||||
val canKick: Boolean
|
||||
val canBan: Boolean
|
||||
|
||||
@@ -10,6 +10,7 @@ package io.element.android.features.space.impl.leave
|
||||
import io.element.android.libraries.architecture.AsyncAction
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
|
||||
data class LeaveSpaceState(
|
||||
val spaceName: String?,
|
||||
@@ -18,10 +19,15 @@ data class LeaveSpaceState(
|
||||
val leaveSpaceAction: AsyncAction<Unit>,
|
||||
val eventSink: (LeaveSpaceEvents) -> Unit,
|
||||
) {
|
||||
private val rooms = selectableSpaceRooms.dataOrNull().orEmpty()
|
||||
private val partition = rooms.partition { it.isLastAdmin }
|
||||
private val lastAdminRooms = partition.first
|
||||
private val selectableRooms = partition.second
|
||||
private val rooms = selectableSpaceRooms.dataOrNull().orEmpty().toImmutableList()
|
||||
private val lastAdminRooms: ImmutableList<SelectableSpaceRoom>
|
||||
private val selectableRooms: ImmutableList<SelectableSpaceRoom>
|
||||
|
||||
init {
|
||||
val partition = rooms.partition { it.isLastAdmin }
|
||||
lastAdminRooms = partition.first.toImmutableList()
|
||||
selectableRooms = partition.second.toImmutableList()
|
||||
}
|
||||
|
||||
/**
|
||||
* True if we should show the quick action to select/deselect all rooms.
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id("io.element.android-library")
|
||||
id("io.element.android-compose-library")
|
||||
id("kotlin-parcelize")
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,11 @@
|
||||
|
||||
package io.element.android.features.verifysession.impl.incoming
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.Stable
|
||||
import io.element.android.libraries.matrix.api.core.DeviceId
|
||||
import io.element.android.libraries.matrix.api.verification.SessionVerificationData
|
||||
import io.element.android.libraries.matrix.api.verification.VerificationRequest
|
||||
|
||||
@Immutable
|
||||
data class IncomingVerificationState(
|
||||
val step: Step,
|
||||
val request: VerificationRequest.Incoming,
|
||||
|
||||
@@ -7,13 +7,11 @@
|
||||
|
||||
package io.element.android.features.verifysession.impl.outgoing
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.runtime.Stable
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.matrix.api.verification.SessionVerificationData
|
||||
import io.element.android.libraries.matrix.api.verification.VerificationRequest
|
||||
|
||||
@Immutable
|
||||
data class OutgoingVerificationState(
|
||||
val step: Step,
|
||||
val request: VerificationRequest.Outgoing,
|
||||
|
||||
@@ -26,7 +26,6 @@ import androidx.compose.ui.graphics.Color
|
||||
/**
|
||||
* This class holds all the semantic tokens of the Compound theme.
|
||||
*/
|
||||
@Immutable
|
||||
data class SemanticColors(
|
||||
/** Background colour for accent or brand actions. State: Hover */
|
||||
val bgAccentHovered: Color,
|
||||
|
||||
@@ -7,11 +7,9 @@
|
||||
|
||||
package io.element.android.libraries.designsystem.components.avatar
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.core.data.tryOrNull
|
||||
import java.text.BreakIterator
|
||||
|
||||
@Immutable
|
||||
data class AvatarData(
|
||||
val id: String,
|
||||
val name: String?,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id("io.element.android-library")
|
||||
id("io.element.android-compose-library")
|
||||
}
|
||||
|
||||
android {
|
||||
|
||||
@@ -156,8 +156,8 @@ public class CameraPositionState(
|
||||
/**
|
||||
* The default saver implementation for [CameraPositionState].
|
||||
*/
|
||||
public val Saver: Saver<CameraPositionState, SaveableCameraPositionState> = Saver(
|
||||
save = { SaveableCameraPositionState(it.position, it.cameraMode.toInternal()) },
|
||||
public val Saver: Saver<CameraPositionState, SaveableCameraPositionData> = Saver(
|
||||
save = { SaveableCameraPositionData(it.position, it.cameraMode.toInternal()) },
|
||||
restore = { CameraPositionState(it.position, CameraMode.fromInternal(it.cameraMode)) }
|
||||
)
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public val currentCameraPositionState: CameraPositionState
|
||||
get() = LocalCameraPositionState.current
|
||||
|
||||
@Parcelize
|
||||
public data class SaveableCameraPositionState(
|
||||
public data class SaveableCameraPositionData(
|
||||
val position: CameraPosition,
|
||||
val cameraMode: Int
|
||||
) : Parcelable
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package io.element.android.libraries.matrix.api.room
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.matrix.api.core.EventId
|
||||
import io.element.android.libraries.matrix.api.core.RoomAlias
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
@@ -19,7 +18,6 @@ import io.element.android.libraries.matrix.api.room.tombstone.SuccessorRoom
|
||||
import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
@Immutable
|
||||
data class RoomInfo(
|
||||
val id: RoomId,
|
||||
/** The room's name from the room state event if received from sync, or one that's been computed otherwise. */
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
package io.element.android.libraries.matrix.api.room
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
import io.element.android.libraries.matrix.api.user.MatrixUser
|
||||
|
||||
@@ -24,6 +25,7 @@ data class RoomMember(
|
||||
/**
|
||||
* Role of the RoomMember, based on its [powerLevel].
|
||||
*/
|
||||
@Immutable
|
||||
sealed interface Role {
|
||||
data class Owner(val isCreator: Boolean) : Role
|
||||
data object Admin : Role
|
||||
|
||||
@@ -26,9 +26,9 @@ interface RoomDirectoryList {
|
||||
/**
|
||||
* The current search results as a state flow.
|
||||
*/
|
||||
val state: Flow<State>
|
||||
val state: Flow<SearchResult>
|
||||
|
||||
data class State(
|
||||
data class SearchResult(
|
||||
val hasMoreToLoad: Boolean,
|
||||
val items: List<RoomDescription>,
|
||||
)
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
package io.element.android.libraries.matrix.api.timeline
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.matrix.api.core.EventId
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.core.ThreadId
|
||||
@@ -42,6 +43,7 @@ interface Timeline : AutoCloseable {
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
@Immutable
|
||||
sealed interface Mode : Parcelable {
|
||||
data object Live : Mode
|
||||
data class FocusedOnEvent(val eventId: EventId) : Mode
|
||||
|
||||
@@ -7,10 +7,8 @@
|
||||
|
||||
package io.element.android.libraries.matrix.api.timeline.item.event
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
|
||||
@Immutable
|
||||
data class EventReaction(
|
||||
val key: String,
|
||||
val senders: ImmutableList<ReactionSender>
|
||||
|
||||
@@ -8,10 +8,13 @@
|
||||
package io.element.android.libraries.matrix.api.verification
|
||||
|
||||
import android.os.Parcelable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
@Immutable
|
||||
sealed interface VerificationRequest : Parcelable {
|
||||
@Immutable
|
||||
sealed interface Outgoing : VerificationRequest {
|
||||
@Parcelize
|
||||
data object CurrentSession : Outgoing
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package io.element.android.libraries.matrix.impl.room
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.core.extensions.runCatchingExceptions
|
||||
import io.element.android.libraries.matrix.api.core.SessionId
|
||||
import io.element.android.libraries.matrix.api.room.NotJoinedRoom
|
||||
@@ -15,7 +14,6 @@ import io.element.android.libraries.matrix.api.room.RoomMembershipDetails
|
||||
import io.element.android.libraries.matrix.api.room.preview.RoomPreviewInfo
|
||||
import io.element.android.libraries.matrix.impl.room.member.RoomMemberMapper
|
||||
|
||||
@Immutable
|
||||
class NotJoinedRustRoom(
|
||||
private val sessionId: SessionId,
|
||||
override val localRoom: RustBaseRoom?,
|
||||
|
||||
@@ -73,9 +73,9 @@ class RustRoomDirectoryList(
|
||||
return !inner.isAtLastPage()
|
||||
}
|
||||
|
||||
override val state: Flow<RoomDirectoryList.State> =
|
||||
override val state: Flow<RoomDirectoryList.SearchResult> =
|
||||
combine(hasMoreToLoad, processor.roomDescriptionsFlow) { hasMoreToLoad, items ->
|
||||
RoomDirectoryList.State(
|
||||
RoomDirectoryList.SearchResult(
|
||||
hasMoreToLoad = hasMoreToLoad,
|
||||
items = items
|
||||
)
|
||||
|
||||
@@ -42,7 +42,7 @@ class RustBaseRoomDirectoryListTest {
|
||||
)
|
||||
val initialItem = awaitItem()
|
||||
assertThat(initialItem).isEqualTo(
|
||||
RoomDirectoryList.State(
|
||||
RoomDirectoryList.SearchResult(
|
||||
hasMoreToLoad = true,
|
||||
items = listOf(mapper.map(aRustRoomDescription()))
|
||||
)
|
||||
@@ -57,7 +57,7 @@ class RustBaseRoomDirectoryListTest {
|
||||
)
|
||||
val nextItem = awaitItem()
|
||||
assertThat(nextItem).isEqualTo(
|
||||
RoomDirectoryList.State(
|
||||
RoomDirectoryList.SearchResult(
|
||||
hasMoreToLoad = false,
|
||||
items = listOf(
|
||||
mapper.map(aRustRoomDescription()),
|
||||
@@ -66,7 +66,7 @@ class RustBaseRoomDirectoryListTest {
|
||||
)
|
||||
val finalItem = awaitItem()
|
||||
assertThat(finalItem).isEqualTo(
|
||||
RoomDirectoryList.State(
|
||||
RoomDirectoryList.SearchResult(
|
||||
hasMoreToLoad = false,
|
||||
items = listOf(
|
||||
mapper.map(aRustRoomDescription()),
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
package io.element.android.libraries.matrix.test.room
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import io.element.android.libraries.matrix.api.room.BaseRoom
|
||||
import io.element.android.libraries.matrix.api.room.NotJoinedRoom
|
||||
import io.element.android.libraries.matrix.api.room.RoomMembershipDetails
|
||||
@@ -15,7 +14,6 @@ import io.element.android.libraries.matrix.api.room.preview.RoomPreviewInfo
|
||||
import io.element.android.tests.testutils.lambda.lambdaError
|
||||
import io.element.android.tests.testutils.simulateLongTask
|
||||
|
||||
@Immutable
|
||||
class FakeNotJoinedRoom(
|
||||
override val localRoom: BaseRoom? = null,
|
||||
override val previewInfo: RoomPreviewInfo = aRoomPreviewInfo(),
|
||||
|
||||
@@ -12,7 +12,7 @@ import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.emptyFlow
|
||||
|
||||
class FakeRoomDirectoryList(
|
||||
override val state: Flow<RoomDirectoryList.State> = emptyFlow(),
|
||||
override val state: Flow<RoomDirectoryList.SearchResult> = emptyFlow(),
|
||||
val filterLambda: (String?, Int, String?) -> Result<Unit> = { _, _, _ -> Result.success(Unit) },
|
||||
val loadMoreLambda: () -> Result<Unit> = { Result.success(Unit) }
|
||||
) : RoomDirectoryList {
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
package io.element.android.libraries.matrix.ui.model
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.Immutable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
@@ -21,7 +20,6 @@ import io.element.android.libraries.matrix.api.core.UserId
|
||||
import io.element.android.libraries.matrix.api.room.RoomMember
|
||||
import io.element.android.libraries.matrix.ui.R
|
||||
|
||||
@Immutable
|
||||
data class InviteSender(
|
||||
val userId: UserId,
|
||||
val displayName: String,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
plugins {
|
||||
id("io.element.android-library")
|
||||
id("io.element.android-compose-library")
|
||||
}
|
||||
|
||||
android {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
plugins {
|
||||
id("io.element.android-library")
|
||||
id("io.element.android-compose-library")
|
||||
}
|
||||
|
||||
android {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
plugins {
|
||||
id("io.element.android-library")
|
||||
id("io.element.android-compose-library")
|
||||
}
|
||||
|
||||
android {
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
package io.element.android.libraries.sessionstorage.api
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
|
||||
@Immutable
|
||||
sealed interface LoggedInState {
|
||||
data object NotLoggedIn : LoggedInState
|
||||
data class LoggedIn(
|
||||
|
||||
@@ -128,15 +128,15 @@ class MarkdownTextEditorState(
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
data class SavedState(
|
||||
data class SavedValue(
|
||||
val text: CharSequence,
|
||||
val selectionStart: Int,
|
||||
val selectionEnd: Int,
|
||||
) : Parcelable
|
||||
}
|
||||
|
||||
object MarkdownTextEditorStateSaver : Saver<MarkdownTextEditorState, MarkdownTextEditorState.SavedState> {
|
||||
override fun restore(value: MarkdownTextEditorState.SavedState): MarkdownTextEditorState {
|
||||
object MarkdownTextEditorStateSaver : Saver<MarkdownTextEditorState, MarkdownTextEditorState.SavedValue> {
|
||||
override fun restore(value: MarkdownTextEditorState.SavedValue): MarkdownTextEditorState {
|
||||
return MarkdownTextEditorState(
|
||||
initialText = "",
|
||||
initialFocus = false,
|
||||
@@ -146,8 +146,8 @@ object MarkdownTextEditorStateSaver : Saver<MarkdownTextEditorState, MarkdownTex
|
||||
}
|
||||
}
|
||||
|
||||
override fun SaverScope.save(value: MarkdownTextEditorState): MarkdownTextEditorState.SavedState {
|
||||
return MarkdownTextEditorState.SavedState(
|
||||
override fun SaverScope.save(value: MarkdownTextEditorState): MarkdownTextEditorState.SavedValue {
|
||||
return MarkdownTextEditorState.SavedValue(
|
||||
text = value.text.value(),
|
||||
selectionStart = value.selection.first,
|
||||
selectionEnd = value.selection.last,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Please see LICENSE files in the repository root for full details.
|
||||
*/
|
||||
plugins {
|
||||
id("io.element.android-library")
|
||||
id("io.element.android-compose-library")
|
||||
}
|
||||
|
||||
android {
|
||||
|
||||
@@ -7,11 +7,14 @@
|
||||
|
||||
package io.element.android.libraries.troubleshoot.api.test
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
|
||||
data class NotificationTroubleshootTestState(
|
||||
val name: String,
|
||||
val description: String,
|
||||
val status: Status,
|
||||
) {
|
||||
@Immutable
|
||||
sealed interface Status {
|
||||
data class Idle(val visible: Boolean) : Status
|
||||
data object InProgress : Status
|
||||
|
||||
@@ -158,7 +158,6 @@ fun Project.setupKover() {
|
||||
"io.element.android.libraries.designsystem.swipe.SwipeableActionsState",
|
||||
"io.element.android.libraries.designsystem.theme.components.bottomsheet.CustomSheetState",
|
||||
"io.element.android.libraries.maplibre.compose.CameraPositionState",
|
||||
"io.element.android.libraries.maplibre.compose.SaveableCameraPositionState",
|
||||
"io.element.android.libraries.maplibre.compose.SymbolState",
|
||||
"io.element.android.libraries.matrix.api.room.RoomMembershipState",
|
||||
"io.element.android.libraries.matrix.api.room.RoomMembersState",
|
||||
|
||||
@@ -7,8 +7,12 @@
|
||||
|
||||
package io.element.android.tests.konsist
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.lemonappdev.konsist.api.Konsist
|
||||
import com.lemonappdev.konsist.api.ext.list.withAnnotationOf
|
||||
import com.lemonappdev.konsist.api.ext.list.withNameEndingWith
|
||||
import com.lemonappdev.konsist.api.ext.list.withoutName
|
||||
import com.lemonappdev.konsist.api.verify.assertEmpty
|
||||
import com.lemonappdev.konsist.api.verify.assertFalse
|
||||
import org.junit.Test
|
||||
|
||||
@@ -60,4 +64,14 @@ class KonsistImmutableTest {
|
||||
it.text.contains(".toPersistentMap()")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Immutable annotation is not used on sealed interface for Presenter Events`() {
|
||||
Konsist
|
||||
.scopeFromProduction()
|
||||
.interfaces()
|
||||
.withNameEndingWith("Events")
|
||||
.withAnnotationOf(Immutable::class)
|
||||
.assertEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
23
tools/compose/check_stability.sh
Executable file
23
tools/compose/check_stability.sh
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2025 New Vector Ltd.
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
# Please see LICENSE files in the repository root for full details.
|
||||
|
||||
set -e
|
||||
|
||||
# Build the project with compose report
|
||||
echo "Building the project with compose report..."
|
||||
./gradlew assembleGplayDebug -PcomposeCompilerReports=true -PcomposeCompilerMetrics=true --stacktrace
|
||||
|
||||
echo "Checking stability of State classes..."
|
||||
# Using the find command, list all the files ending with -classes.txt
|
||||
find . -type f -name "*-classes.txt" | while read -r file; do
|
||||
# echo "Processing $file"
|
||||
# Check that there is no line containing "unstable class .*State {"
|
||||
if grep -E 'unstable class .*State \{' "$file"; then
|
||||
echo "❌ ERROR: Found unstable State class in $file"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user