Skip to content
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

[Feature] Pinned messages list #3392

Merged
merged 23 commits into from
Sep 6, 2024
Merged

Conversation

ganfra
Copy link
Member

@ganfra ganfra commented Sep 4, 2024

Content

Add the Pinned messages list screen and all the ways to navigate (from it and to it).

Motivation and context

Closes #3214

Screenshots / GIFs

See recorded screenshots in the PR.

Tests

  • Open a room with pinned events
  • Click on the "View all" pinned banner button
  • Interacts with the pinned events timeline (long click etc etc).

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

  • Changes have been tested on an Android device or Android emulator with API 23
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • Pull request includes a sign off
  • You've made a self review of your PR

@ganfra ganfra added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Sep 4, 2024
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Sep 4, 2024
@ganfra ganfra added the PR-Wip For anything that isn't ready to ship and will be enabled at a later date label Sep 4, 2024
Copy link
Contributor

github-actions bot commented Sep 4, 2024

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/iPS227

@ganfra ganfra marked this pull request as ready for review September 4, 2024 15:52
@ganfra ganfra requested a review from a team as a code owner September 4, 2024 15:52
@ganfra ganfra requested review from bmarty and removed request for a team September 4, 2024 15:52
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, thanks!
Only a few remarks, and I have found a small bug, which is not blocking I think.

val actionListState: ActionListState,
val eventSink: (PinnedMessagesListEvents) -> Unit,
) : PinnedMessagesListState {
val loadedPinnedMessagesCount = timelineItems.count { timelineItem -> timelineItem is TimelineItem.Event }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have other TimelineItem types in timelineItems?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we do have day divider as virtual items

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, thanks.

aLoadingPinnedMessagesListState(),
anEmptyPinnedMessagesListState(),
aLoadedPinnedMessagesListState(
timelineItems = aTimelineItemList(aTimelineItemTextContent())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use a better list to have a more realistic preview:

image

is a bit wrong.

And maybe include a Poll to check the rendering of this code.

is TimelineItemAction.ViewSource -> true
else -> false
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clever way to build the actions, hence in this case, I think "Unpin" could be displayed before "Forward" (as per the design by the way)

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed a bit to fix the ordering

if (pushToBackstack) {
backstack.push(target)
} else {
backstack.singleTop(target)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not have any effect if the target is already in the stack.

To repro the issue:

  1. Navigate to the All pinned event
  2. on pinned event X, select View in timeline
  3. Repeat 1 and 2 (using the same event): nothing happen.

To fix, maybe add a random int field in NavTarget.Room?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, good catch

import io.element.android.features.messages.impl.actionlist.model.TimelineItemAction
import io.element.android.features.messages.impl.actionlist.model.TimelineItemActionPostProcessor

object PinnedMessagesListTimelineActionPostProcessor : TimelineItemActionPostProcessor {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be a regular class instead?

interface Callback : Plugin {
fun onRoomDetailsClick()
fun onUserDataClick(userId: UserId)
fun onPermalinkClick(data: PermalinkData)
fun onPermalinkClick(data: PermalinkData, pushToBackstack: Boolean = true)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe safer to avoid default values for parameters. I let you decide.

enum class Mode {
LIVE,
FOCUSED_ON_EVENT,
FOCUSED_ON_PINNED_EVENTS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FOCUSED_ON_PINNED_EVENTS is a bit confusing to me. In this mode, only the Pinned Events will be in the items, right? So maybe rename to PINNED_EVENTS, or PINNED_EVENTS_ONLY?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's because this is a focused timeline underneath, but I agree it's a bit confusing.

@ganfra ganfra added the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Sep 5, 2024
@github-actions github-actions bot removed the Record-Screenshots Runs the 'Record Screenshots' CI job and adds a commit with any new screenshots found. label Sep 5, 2024
Copy link

sonarcloud bot commented Sep 5, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

Copy link

codecov bot commented Sep 5, 2024

Codecov Report

Attention: Patch coverage is 83.23108% with 82 lines in your changes missing coverage. Please review.

Project coverage is 82.57%. Comparing base (2c8b0d0) to head (332e38b).
Report is 69 commits behind head on develop.

Files with missing lines Patch % Lines
...essages/impl/pinned/list/PinnedMessagesListView.kt 80.16% 18 Missing and 6 partials ⚠️
...es/impl/pinned/list/PinnedMessagesListPresenter.kt 85.71% 2 Missing and 11 partials ⚠️
...imeline/components/TimelineItemGroupedEventsRow.kt 29.41% 12 Missing ⚠️
...ssages/impl/pinned/PinnedEventsTimelineProvider.kt 74.19% 6 Missing and 2 partials ⚠️
...t/PinnedMessagesListTimelineActionPostProcessor.kt 14.28% 6 Missing ⚠️
...eatures/messages/impl/DefaultMessagesEntryPoint.kt 0.00% 4 Missing ⚠️
...mpl/pinned/banner/PinnedMessagesBannerPresenter.kt 88.23% 2 Missing and 2 partials ⚠️
...es/messages/impl/actionlist/ActionListPresenter.kt 90.90% 1 Missing and 2 partials ⚠️
.../android/libraries/matrix/api/timeline/Timeline.kt 0.00% 3 Missing ⚠️
...droid/features/roomdetails/impl/RoomDetailsView.kt 81.81% 0 Missing and 2 partials ⚠️
... and 3 more
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3392      +/-   ##
===========================================
- Coverage    82.60%   82.57%   -0.03%     
===========================================
  Files         1694     1703       +9     
  Lines        39651    40027     +376     
  Branches      4821     4866      +45     
===========================================
+ Hits         32752    33051     +299     
- Misses        5216     5270      +54     
- Partials      1683     1706      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ganfra ganfra requested a review from bmarty September 5, 2024 17:04
@ganfra ganfra added the Run-Maestro Starts a Maestro Cloud session to run integration tests label Sep 6, 2024
@github-actions github-actions bot removed the Run-Maestro Starts a Maestro Cloud session to run integration tests label Sep 6, 2024
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update!

cancelAndIgnoreRemainingEvents()
assert(unpinEventLambda)

assert(successUnpinEventLambda)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assertion should be done earlier, else the test does not check the order of the lambda invocation.

),
aTimelineItemEvent(
isMine = true,
content = aTimelineItemFileContent("A pinned file?"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:)

@ganfra ganfra merged commit b802a19 into develop Sep 6, 2024
28 of 29 checks passed
@ganfra ganfra deleted the feature/fga/pinned_messages_list branch September 6, 2024 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Wip For anything that isn't ready to ship and will be enabled at a later date
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Task] Pinned items timeline
2 participants