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

Images in messages with different max height #4315

Merged
merged 3 commits into from
Nov 27, 2024
Merged

Conversation

nicodh
Copy link
Member

@nicodh nicodh commented Nov 4, 2024

No description provided.

@nicodh nicodh changed the title Image attachement test Images in messages with different max height Nov 4, 2024
@nicodh nicodh marked this pull request as draft November 4, 2024 19:41
@nicodh nicodh requested a review from WofWca November 4, 2024 19:41
@nicodh
Copy link
Member Author

nicodh commented Nov 4, 2024

I rebased that to PR #4313 for easier testing - just a proposal to avoid too small images in message list

Copy link
Collaborator

@WofWca WofWca left a comment

Choose a reason for hiding this comment

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

I'd say it looks better now most of the time. But perhaps 800px is a bit too much, because on common monitors such images don't fit on screen unless you have Delta Chat maximized. Maybe max-height: calc(min(60vh, 800px)) would work better.

And super small images look funny. IDK if we call it a bug or a feature:
image
But they're impossible to click on. Maybe min-height or min-width would help.

Copy link
Collaborator

@WofWca WofWca left a comment

Choose a reason for hiding this comment

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

I just discovered that the new height also applies to stickers. I suppose it shouldn't be the case.

@maxphilippov
Copy link
Collaborator

maxphilippov commented Nov 13, 2024

May I propose a different solution? If I understand the issue correctly.


We have here dimensionWidth and dimensionHeight as part of message object.

We can do something like this to both handle max height and layout jumping when messages load (and maybe also add a minimum height):

    const dimensionsHeight = Math.min(message.dimensionsHeight, 200)
    const dimensionsWidth = message.dimensionsWidth * dimensionsHeight / message.dimensionsHeight

    return (
      <button
        onClick={onClickAttachment}
        className={classNames(
          'message-attachment-media',
          withCaption ? 'content-below' : null,
          withContentAbove ? 'content-above' : null
        )}
      >
        <img
          className='attachment-content'
	  width={dimensionsWidth}
	  height={dimensionsHeight}
          src={runtime.transformBlobURL(message.file)}
        />
      </button>
    )

@WofWca
Copy link
Collaborator

WofWca commented Nov 15, 2024

Also let's keep reactions in mind:

image

@nicodh nicodh force-pushed the image-attachement-test branch from a6b5740 to 9218f5b Compare November 25, 2024 21:53
@nicodh
Copy link
Member Author

nicodh commented Nov 25, 2024

I would suggest to merge this now, since it improves many situations. There might be a better solution, by applying various calculations but that should not be part of this PR...

@nicodh nicodh requested a review from WofWca November 25, 2024 21:55
Copy link
Collaborator

@WofWca WofWca left a comment

Choose a reason for hiding this comment

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

I'm a bit reluctant to approve this since firstly this doesn't actually fix the issue of reactions overflowing narrow image-messages, and secondly this can introduce unexpected consequences (as with stickers).
But the next release is far away, and if we're up for a bit of trial and error, then let's do it.

(FYI a changelog entry is missing)

packages/frontend/scss/message/_message-attachment.scss Outdated Show resolved Hide resolved
packages/frontend/scss/message/_message-attachment.scss Outdated Show resolved Hide resolved
@WofWca
Copy link
Collaborator

WofWca commented Nov 27, 2024

We can do something like this to both handle max height and layout jumping when messages load (and maybe also add a minimum height):

@maxphilippov Yes, layout jumping needs to be fixed, but I'd say it can be tackled separately.

Also for that I'd suggest to still utilize CSS instead of JS, and pass these JS-provided values as CSS variables.

@nicodh nicodh force-pushed the image-attachement-test branch from 9218f5b to c9fc40b Compare November 27, 2024 16:29
@nicodh nicodh marked this pull request as ready for review November 27, 2024 16:29
@nicodh nicodh merged commit db83279 into main Nov 27, 2024
10 checks passed
@nicodh nicodh deleted the image-attachement-test branch November 27, 2024 16:34
WofWca added a commit that referenced this pull request Dec 22, 2024
Because of `max-width: 80%`, which refers to 80% of the wrapper
square, and not the chat section
(the later was apparently the intention).
This has been introduced in #4315,
which has later been sort of reverted, but not completely, in
#4407.
So, let's remove the residuals, especially that stickers also have
fixed `height: 200px`, so `max-height` doesn't make sense.
WofWca added a commit that referenced this pull request Dec 22, 2024
Because of `max-width: 80%`, which refers to 80% of the wrapper
square, and not the chat section
(the later was apparently the intention).
This has been introduced in #4315,
which has later been sort of reverted, but not completely, in
#4407.
So, let's remove the residuals, especially that stickers also have
fixed `height: 200px`, so `max-height` doesn't make sense.
WofWca added a commit that referenced this pull request Jan 6, 2025
Because of `max-width: 80%`, which refers to 80% of the wrapper
square, and not the chat section
(the later was apparently the intention).
This has been introduced in #4315,
which has later been sort of reverted, but not completely, in
#4407.
So, let's remove the residuals, especially that stickers also have
fixed `height: 200px`, so `max-height` doesn't make sense.
WofWca added a commit that referenced this pull request Jan 6, 2025
Because of `max-width: 80%`, which refers to 80% of the wrapper
square, and not the chat section
(the later was apparently the intention).
This has been introduced in #4315,
which has later been sort of reverted, but not completely, in
#4407.
So, let's remove the residuals, especially that stickers also have
fixed `height: 200px`, so `max-height` doesn't make sense.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants