Merge pull request #4029 from element-hq/feature/bma/eventCache
Add a feature flag to be able to enable the event cache
This commit is contained in:
@@ -61,6 +61,10 @@ fun RoomListContextMenu(
|
||||
onFavoriteChange = { isFavorite ->
|
||||
eventSink(RoomListEvents.SetRoomIsFavorite(contextMenu.roomId, isFavorite))
|
||||
},
|
||||
onClearCacheRoomClick = {
|
||||
eventSink(RoomListEvents.HideContextMenu)
|
||||
eventSink(RoomListEvents.ClearCacheOfRoom(contextMenu.roomId))
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -73,6 +77,7 @@ private fun RoomListModalBottomSheetContent(
|
||||
onFavoriteChange: (isFavorite: Boolean) -> Unit,
|
||||
onRoomMarkReadClick: () -> Unit,
|
||||
onRoomMarkUnreadClick: () -> Unit,
|
||||
onClearCacheRoomClick: () -> Unit,
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -177,6 +182,18 @@ private fun RoomListModalBottomSheetContent(
|
||||
),
|
||||
style = ListItemStyle.Destructive,
|
||||
)
|
||||
if (contextMenu.eventCacheFeatureFlagEnabled) {
|
||||
ListItem(
|
||||
headlineContent = {
|
||||
Text(text = "Clear cache for this room")
|
||||
},
|
||||
modifier = Modifier.clickable { onClearCacheRoomClick() },
|
||||
leadingContent = ListItemContent.Icon(
|
||||
iconSource = IconSource.Vector(CompoundIcons.Delete())
|
||||
),
|
||||
style = ListItemStyle.Primary,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,5 +212,6 @@ internal fun RoomListModalBottomSheetContentPreview(
|
||||
onRoomSettingsClick = {},
|
||||
onLeaveRoomClick = {},
|
||||
onFavoriteChange = {},
|
||||
onClearCacheRoomClick = {},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -25,4 +25,5 @@ sealed interface RoomListEvents {
|
||||
data class MarkAsRead(val roomId: RoomId) : ContextMenuEvents
|
||||
data class MarkAsUnread(val roomId: RoomId) : ContextMenuEvents
|
||||
data class SetRoomIsFavorite(val roomId: RoomId, val isFavorite: Boolean) : ContextMenuEvents
|
||||
data class ClearCacheOfRoom(val roomId: RoomId) : ContextMenuEvents
|
||||
}
|
||||
|
||||
@@ -146,6 +146,7 @@ class RoomListPresenter @Inject constructor(
|
||||
AcceptDeclineInviteEvents.DeclineInvite(event.roomListRoomSummary.toInviteData())
|
||||
)
|
||||
}
|
||||
is RoomListEvents.ClearCacheOfRoom -> coroutineScope.clearCacheOfRoom(event.roomId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,7 +256,8 @@ class RoomListPresenter @Inject constructor(
|
||||
isDm = event.roomListRoomSummary.isDm,
|
||||
isFavorite = event.roomListRoomSummary.isFavorite,
|
||||
markAsUnreadFeatureFlagEnabled = featureFlagService.isFeatureEnabled(FeatureFlags.MarkAsUnread),
|
||||
hasNewContent = event.roomListRoomSummary.hasNewContent
|
||||
hasNewContent = event.roomListRoomSummary.hasNewContent,
|
||||
eventCacheFeatureFlagEnabled = featureFlagService.isFeatureEnabled(FeatureFlags.EventCache),
|
||||
)
|
||||
contextMenuState.value = initialState
|
||||
|
||||
@@ -312,6 +314,12 @@ class RoomListPresenter @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun CoroutineScope.clearCacheOfRoom(roomId: RoomId) = launch {
|
||||
client.getRoom(roomId)?.use { room ->
|
||||
room.clearEventCacheStorage()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the user needs to migrate to a native sliding sync version.
|
||||
*/
|
||||
|
||||
@@ -46,6 +46,7 @@ data class RoomListState(
|
||||
val isDm: Boolean,
|
||||
val isFavorite: Boolean,
|
||||
val markAsUnreadFeatureFlagEnabled: Boolean,
|
||||
val eventCacheFeatureFlagEnabled: Boolean,
|
||||
val hasNewContent: Boolean,
|
||||
) : ContextMenu
|
||||
}
|
||||
|
||||
@@ -31,4 +31,5 @@ internal fun aContextMenuShown(
|
||||
markAsUnreadFeatureFlagEnabled = true,
|
||||
hasNewContent = hasNewContent,
|
||||
isFavorite = isFavorite,
|
||||
eventCacheFeatureFlagEnabled = false,
|
||||
)
|
||||
|
||||
@@ -288,6 +288,7 @@ class RoomListPresenterTest {
|
||||
isDm = false,
|
||||
isFavorite = false,
|
||||
markAsUnreadFeatureFlagEnabled = true,
|
||||
eventCacheFeatureFlagEnabled = false,
|
||||
hasNewContent = false,
|
||||
)
|
||||
)
|
||||
@@ -305,6 +306,7 @@ class RoomListPresenterTest {
|
||||
isDm = false,
|
||||
isFavorite = true,
|
||||
markAsUnreadFeatureFlagEnabled = true,
|
||||
eventCacheFeatureFlagEnabled = false,
|
||||
hasNewContent = false,
|
||||
)
|
||||
)
|
||||
@@ -335,6 +337,7 @@ class RoomListPresenterTest {
|
||||
isDm = false,
|
||||
isFavorite = false,
|
||||
markAsUnreadFeatureFlagEnabled = true,
|
||||
eventCacheFeatureFlagEnabled = false,
|
||||
hasNewContent = false,
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user