Skip to content

Conversation

@jeremygooch
Copy link
Contributor

In reference to: #790

This PR adds a Collapse component to long running messages. The height of the message preview is configurable in the Message component, as is the animation timeout. The animation timeout is also used to determine when to recalculate the height of the Message so it can be sent to the parent component via the height function.

I didn't see any test files for this component that needed to be updated, but lmk if there's anything that needs to be addressed there, or if anything else on the PR needs attention.

Thanks also to @jmattheis for the pointer to the height function.

…ssages. Height is broadcast out to parent on height toggle.

See: gotify#790
@jeremygooch jeremygooch requested a review from a team as a code owner June 29, 2025 17:19
@jeremygooch jeremygooch requested a review from jmattheis June 29, 2025 20:24
@codecov
Copy link

codecov bot commented Jul 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.51%. Comparing base (2498e6e) to head (9f432ad).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #810   +/-   ##
=======================================
  Coverage   79.51%   79.51%           
=======================================
  Files          56       56           
  Lines        2641     2641           
=======================================
  Hits         2100     2100           
  Misses        450      450           
  Partials       91       91           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@jmattheis jmattheis left a comment

Choose a reason for hiding this comment

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

Awesome, looks pretty good. Thanks! I've made some minor cleanup and fixed the height updating. See sub comments.


public togglePreviewHeight = () => {
this.setState({...this.state, expanded: !this.state.expanded});
this.updateHeightInParent();
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't work, as setState is asynchronous, so the size change in the DOM has very likely not happened yet. I've changed this to

        this.setState(
            (state) => ({expanded: !state.expanded}),
            () => this.updateHeightInParent(),
        );

https://legacy.reactjs.org/docs/react-component.html#setstate
the callback should be executed after the setState was applied.

public componentDidMount = () => {
if (this.previewRef.current) {
this.setState({
...this.state,
Copy link
Member

Choose a reason for hiding this comment

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

This can be omitted, as react already does a shallow merge. (already changed)

<Typography
component="div"
ref={this.previewRef}
className={`${classes.content} content ${!this.state.isOverflowing ? 'loading' : this.state.expanded ? 'expanded' : 'collapsed'}`}>
Copy link
Member

Choose a reason for hiding this comment

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

I've simplified this to this.state.isOverflowing && this.state.expanded ? 'expanded' : ''

@jmattheis jmattheis merged commit c1cb2e8 into gotify:master Jul 6, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants