-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5204 from vector-im/feature/fga/reactions_ui_impr…
…ovements Feature/fga/reactions UI improvements
- Loading branch information
Showing
16 changed files
with
205 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Improve UI of reactions in timeline, including quick add reaction. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...n/java/im/vector/app/features/home/room/detail/timeline/helper/ReactionsSummaryFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright (c) 2021 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 im.vector.app.features.home.room.detail.timeline.helper | ||
|
||
import dagger.hilt.android.scopes.ActivityScoped | ||
import im.vector.app.features.home.room.detail.timeline.TimelineEventController | ||
import im.vector.app.features.home.room.detail.timeline.item.ReactionInfoData | ||
import im.vector.app.features.home.room.detail.timeline.item.ReactionsSummaryData | ||
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent | ||
import javax.inject.Inject | ||
|
||
@ActivityScoped | ||
class ReactionsSummaryFactory @Inject constructor() { | ||
|
||
var onRequestBuild: (() -> Unit)? = null | ||
private val showAllReactionsByEvent = HashSet<String>() | ||
private val eventsRequestingBuild = HashSet<String>() | ||
|
||
fun needsRebuild(event: TimelineEvent): Boolean { | ||
return eventsRequestingBuild.remove(event.eventId) | ||
} | ||
|
||
fun create(event: TimelineEvent, callback: TimelineEventController.Callback?): ReactionsSummaryData { | ||
val eventId = event.eventId | ||
val showAllStates = showAllReactionsByEvent.contains(eventId) | ||
val reactions = event.annotations?.reactionsSummary | ||
?.map { | ||
ReactionInfoData(it.key, it.count, it.addedByMe, it.localEchoEvents.isEmpty()) | ||
} | ||
return ReactionsSummaryData( | ||
reactions = reactions, | ||
showAll = showAllStates, | ||
onShowMoreClicked = { | ||
showAllReactionsByEvent.add(eventId) | ||
onRequestBuild(eventId) | ||
}, | ||
onShowLessClicked = { | ||
showAllReactionsByEvent.remove(eventId) | ||
onRequestBuild(eventId) | ||
}, | ||
onAddMoreClicked = { | ||
callback?.onAddMoreReaction(event) | ||
} | ||
) | ||
} | ||
|
||
private fun onRequestBuild(eventId: String) { | ||
eventsRequestingBuild.add(eventId) | ||
onRequestBuild?.invoke() | ||
} | ||
} |
Oops, something went wrong.