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: Show forwarded messages #448

Open
wants to merge 28 commits into
base: develop
Choose a base branch
from

Conversation

julian-wls
Copy link
Contributor

@julian-wls julian-wls commented Feb 28, 2025

Problem Description

Forwarded messages are currently not rendered by the app, and that's why there are sometimes posts with no content in the chat.

Changes

This PR introduces the rendering of forwarded messages by making the required requests and adding logic to correctly match the forwarded posts to their destination posts.
The following changes have been made:

  • extracting and loading functionality for forwarded messages in the PageSource of MetisChatList
  • Replaced PostItemViewType with already existing ChatListItem, and expanding ChatListItem to feature more sub-classes and store forwarded messages
  • Added ForwardedMessageColumn with rendering functionality and conversation matching
  • Changed PostItemMainContent to not show role badges anymore as author role was always null (also for saved messages)
  • added visibility tests for forwarded messages
  • fixed bugs

Note:

Steps for testing

  1. Go to a chat that includes forwarded messages or create some in the web app
  2. Make sure the forwarded messages are shown correctly
  3. Check if the the source conversation is shown correctly and clickable if public
  4. Change the content of a forwarded message and make sure the changes are reflected by the app
  5. Delete the source post of a forwarded message and check if the indication is shown.

Screenshots

Forwarded-messages21

@julian-wls julian-wls added the database changes This PR includes database changes and should be treated with extra care when merging label Feb 28, 2025
@julian-wls julian-wls self-assigned this Feb 28, 2025
@julian-wls julian-wls added the api calls Attention when merging because of the recent 8.0.0 breaking changes label Mar 5, 2025
@julian-wls julian-wls marked this pull request as ready for review March 6, 2025 09:20
@julian-wls julian-wls added the ready for review This PR can be reviewed label Mar 6, 2025
Copy link
Collaborator

@FelberMartin FelberMartin left a comment

Choose a reason for hiding this comment

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

Thank you for working on this, this forwarding thingy really turned out to be much more complex than anticipated :D

Test the functionality and works as described, just a few code comments :)

Box(
modifier = Modifier
.clip(shape = CircleShape)
.fillMaxHeight()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we use exactly the same border also for LinkPreviews, right? If so, we could create a composable for this. It would also improve the readability :D

PostItemMainContent(
modifier = Modifier,
modifier = Modifier.wrapContentHeight(unbounded = true),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Out of curiosity, can you explain why wrapContentHeight is needed here?

val id =
cachedForwardedMessages.find { it.destinationPostId == chatListItem.post.serverPostId }?.sourceId
forwardedSourcePosts = forwardedSourcePosts + (cachedStandaloneSourcePosts[id] ?: emptyList())
forwardedSourcePosts = forwardedSourcePosts + (cachedAnswerSourcePosts[id] ?: emptyList())
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we could make the list mutable and make use of the forwardedSourcePosts += syntax here

* and stored in cachedStandardsSourcePosts and cachedAnswerSourcePosts.
* Common usage: 1. Extract forwarded messages from a list of posts in [extractForwardedMessages].
* 2. Load the forwarded messages for the extracted ids and fetch their source posts in [loadForwardedMessages].
* 3. Match the previously loaded source posts to the destination posts in [resolveForwardedMessages].
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could improve the readability of this class by ordering the method definitions in the ordered they are supposed to be called :D

@@ -117,6 +117,7 @@ internal fun ConversationChatListScreen(

LaunchedEffect(courseId, conversationId) {
chatListState.scrollToItem(0)
viewModel.onCloseThread = null
Copy link
Collaborator

@FelberMartin FelberMartin Mar 8, 2025

Choose a reason for hiding this comment

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

Is this one of the bugfixes mentioned in the PR description? At least from some testing, it looks like it solves #438, so I assigned it accordingly. In case that's wrong, feel free to undo it :D


interface ForwardedMessage {
val forwardedPosts: List<IBasePost?>
val courseId: Long
Copy link
Collaborator

Choose a reason for hiding this comment

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

The courseId feels kinda off here, is it only used for creating the inAppLink? If so, I'd suggest to create a new CommunicationDeepLinks.ToConversationCourseAgnostic, similar to eg ToLectureCourseAgnostic.

Also, would it then make sense to remove the interface ForwardedMessage and its implementations, and instead move forwardedPosts to the PostItem and leave it empty for posts without forwarded messages? But maybe I missed something, please let me know :D

@FelberMartin FelberMartin linked an issue Mar 8, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api calls Attention when merging because of the recent 8.0.0 breaking changes database changes This PR includes database changes and should be treated with extra care when merging ready for review This PR can be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Navigate out of chat after post deletion
2 participants