-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Change to use an unified constant for max media attachments per status #29073
Change to use an unified constant for max media attachments per status #29073
Conversation
73c6f73
to
ee93a5d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall. Some followup ideas to add to this PR or afterwards:
- The
PostStatusService
spec does check the 4 attachment limit -- this could be update to stub_const this new constant limit and simplify the spec (or at minimum, change the hard-coded4
there to just reference the constant). - The
UpdateStatusService
is missing this spec coverage - could be added in similar way.
Thanks @mjankowski could you please help to enable the CI action for this PR? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #29073 +/- ##
==========================================
- Coverage 85.01% 85.00% -0.02%
==========================================
Files 1059 1058 -1
Lines 28277 28282 +5
Branches 4538 4538
==========================================
+ Hits 24040 24041 +1
- Misses 3074 3078 +4
Partials 1163 1163 ☔ View full report in Codecov by Sentry. |
This pull request has merge conflicts that must be resolved before it can be merged. |
This pull request has resolved merge conflicts and is ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Did you try locally to increase the value locally and check that both the UI and the API support the new value?
thanks! yes, I did tested it locally with changing the const number. |
It looks like this is breaking the end-to-end tests in the admin panel, specifically this one: https://github.com/mastodon/mastodon/blob/main/spec/system/report_interface_spec.rb#L23 Can you please look at this and fix it? |
I think the admin panel failure is because the Media Gallery gets mounted out of a redux context there. |
looks like there is some issue with the current main branch, under development mode (in docker), admin@localhost is not approved.. so I can't replicate and test the change, any idea about the "approved" issue? |
You can approve it from the CLI using |
b21618c
to
7f0ca08
Compare
@ClearlyClaire Could you please help with fixing the media gallery in the report view? I'm not very familiar with how redux is used in mastodon, but definitely want to push for this PR. Thanks. |
The Redux store is not initialised at all when we render independent React components in a page (in your case, A way to solve this is to properly initialise Redux when mounting a Another way to do this would be to somehow detect if we are in a Redux context, and if not, fetch this value and pass it to the component, but I do not think we do this in any other place? |
5b209ad
to
78370f3
Compare
78370f3
to
93172ee
Compare
great. CI passed! |
bouncing this up. |
This pull request has merge conflicts that must be resolved before it can be merged. |
This pull request has resolved merge conflicts and is ready for review. |
This PR has been here for ages.. can any one review and see if it can get merged?? |
The authoring part is fine, but I'm not sure about the display part, for the following reasons:
|
@ClearlyClaire I agree with what you said that there will be more work required if we want to support more than 4 media per post. This is why I made it clear in the PR title and description that the intention of this PR is just refactoring to have a constant indicate the limit instead having magic number 3/4 everywhere. Are we fine with the refactoring? |
Makes sense, but I think this would be easier done by:
This would simplify the client-side code greatly and avoid doing an extra request to the API. Further down the line, the UI can be changed to handle arbitrary many attachments in a more graceful way, and the limit can be lifted from the serializer. |
@ClearlyClaire The client side need to be aware of this limit, because it's not only for display but also for uploading:
And still, I believe this PR is helping to move to a better place instead of making it worse. as in the master branch now, the backend is using a constant but magic number 3/4 everywhere in UI code |
I'm not disputing that, what I meant is that we can remove complexity from The changes in |
@ClearlyClaire updated as per your comments |
@ClearlyClaire may I know is it good to be merged now? |
can someone have a look at this PR? it has been there for ages... |
Please keep in mind that the Mastodon core team is very small, and has a lot of work to do (like handling the recent security release). The code changes appear fine, although one of my suggestions is missing:
I think this is important because in the absence of a media gallery redesign, having more than 4 media attachments results in a strictly less usable interface as only considering the 4 first media attachments. Furthermore, old versions of Mastodon used to not discard media attachments above 4 attachments, so viewing such posts would result in a degraded experience. I will try to tackle these server-side changes myself soon, and I think this PR can be merged as soon as this is implemented. But to be truly useful, the media gallery needs to be redesigned to gracefully handle more than 4 attachments. |
thanks, apart form #30932, anything you think we need for this PR? @ClearlyClaire |
Currently, there are multiple places referring a hard coded magic number 4 as the max media attachment per status. This PR is creating a constant in MediaAttaments Mode to unifying the definition.
both JS and ruby will use the same definition.