-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Room list room summary cleanup #2273
Changes from 8 commits
4924f86
579f4d6
7fee884
ed1112f
8eba125
7832eb7
5caebaa
9460bcd
4739222
bbd8710
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (c) 2024 New Vector Ltd | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.element.android.features.roomlist.impl.datasource | ||
|
||
import io.element.android.features.roomlist.impl.model.RoomListRoomSummary | ||
import io.element.android.libraries.core.extensions.orEmpty | ||
import io.element.android.libraries.dateformatter.api.LastMessageTimestampFormatter | ||
import io.element.android.libraries.designsystem.components.avatar.AvatarData | ||
import io.element.android.libraries.designsystem.components.avatar.AvatarSize | ||
import io.element.android.libraries.eventformatter.api.RoomLastMessageFormatter | ||
import io.element.android.libraries.matrix.api.core.RoomId | ||
import io.element.android.libraries.matrix.api.roomlist.RoomSummary | ||
import kotlinx.collections.immutable.ImmutableList | ||
import kotlinx.collections.immutable.toImmutableList | ||
import javax.inject.Inject | ||
|
||
class RoomListRoomSummaryFactory @Inject constructor( | ||
private val lastMessageTimestampFormatter: LastMessageTimestampFormatter, | ||
private val roomLastMessageFormatter: RoomLastMessageFormatter, | ||
) { | ||
fun createPlaceholder(id: String): RoomListRoomSummary { | ||
return RoomListRoomSummary( | ||
id = id, | ||
roomId = RoomId("!aRoom:domain"), | ||
isPlaceholder = true, | ||
name = "Short name", | ||
timestamp = "hh:mm", | ||
lastMessage = "Last message for placeholder", | ||
avatarData = AvatarData(id, "S", size = AvatarSize.RoomListItem), | ||
hasUnread = false, | ||
userDefinedNotificationMode = null, | ||
hasRoomCall = false, | ||
isDm = false, | ||
) | ||
} | ||
|
||
fun createFakeList(): ImmutableList<RoomListRoomSummary> { | ||
return List(16) { | ||
createPlaceholder("!fakeRoom$it:domain") | ||
}.toImmutableList() | ||
} | ||
|
||
fun create(roomSummary: RoomSummary.Filled): RoomListRoomSummary { | ||
val roomIdentifier = roomSummary.identifier() | ||
val avatarData = AvatarData( | ||
id = roomIdentifier, | ||
name = roomSummary.details.name, | ||
url = roomSummary.details.avatarUrl, | ||
size = AvatarSize.RoomListItem, | ||
) | ||
return RoomListRoomSummary( | ||
id = roomIdentifier, | ||
roomId = RoomId(roomIdentifier), | ||
name = roomSummary.details.name, | ||
hasUnread = roomSummary.details.unreadNotificationCount > 0, | ||
timestamp = lastMessageTimestampFormatter.format(roomSummary.details.lastMessageTimestamp), | ||
lastMessage = roomSummary.details.lastMessage?.let { message -> | ||
roomLastMessageFormatter.format(message.event, roomSummary.details.isDirect) | ||
}.orEmpty(), | ||
avatarData = avatarData, | ||
isPlaceholder = false, | ||
userDefinedNotificationMode = roomSummary.details.userDefinedNotificationMode, | ||
hasRoomCall = roomSummary.details.hasRoomCall, | ||
isDm = roomSummary.details.isDm, | ||
) | ||
} | ||
} |
This file was deleted.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no timestamp if no message. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm fine with not displaying the timestamp if there's no last message, but Could we change this return type to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I did not change any logic in the existing codebase, just wanted to have more coherent previews. But you're right, since if we want to change this, it should be done in a separate PR, as this one is only rework with no logical change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id has changed, and so the avatar color.