[Feature] Remove hardcoded limit of media (#11)
Fixes #7 The limit of upload and remote display media was hard coded to 4. In this PR, I did the following changes: - Status form now respects instance's upload limit config. - Remove the limit of images shown on statuses - Remote statuses may have more than local instance's limit Also, I kept the 16:9 aspect ratio of the images. I can change to more complex layouts in future PRs if needed. This works, but it needs more tests. I don't have how to change the config of my instance, so I had to test forcing duplicates on the post. Any help to validate configuration would be nice.  Reviewed-on: https://codeberg.org/superseriousbusiness/masto-fe-standalone/pulls/11 Co-authored-by: Thiago 'Jedi' Cerqueira <thiagoa7@gmail.com> Co-committed-by: Thiago 'Jedi' Cerqueira <thiagoa7@gmail.com>
This commit is contained in:
committed by
tobi
parent
b15856c5fc
commit
4bb7992d4c
@@ -319,7 +319,7 @@ export function uploadCompose(files) {
|
|||||||
dispatch(uploadComposeRequest());
|
dispatch(uploadComposeRequest());
|
||||||
|
|
||||||
for (const [i, f] of Array.from(files).entries()) {
|
for (const [i, f] of Array.from(files).entries()) {
|
||||||
if (media.size + i > 3) break;
|
if (media.size + i >= uploadLimit) break;
|
||||||
|
|
||||||
resizeImage(f).then(file => {
|
resizeImage(f).then(file => {
|
||||||
const data = new FormData();
|
const data = new FormData();
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ class Item extends PureComponent {
|
|||||||
visible: PropTypes.bool.isRequired,
|
visible: PropTypes.bool.isRequired,
|
||||||
autoplay: PropTypes.bool,
|
autoplay: PropTypes.bool,
|
||||||
useBlurhash: PropTypes.bool,
|
useBlurhash: PropTypes.bool,
|
||||||
|
imageStyle: PropTypes.object,
|
||||||
};
|
};
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
@@ -116,6 +117,7 @@ class Item extends PureComponent {
|
|||||||
displayWidth,
|
displayWidth,
|
||||||
visible,
|
visible,
|
||||||
useBlurhash,
|
useBlurhash,
|
||||||
|
imageStyle
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
let badges = [], thumbnail;
|
let badges = [], thumbnail;
|
||||||
@@ -182,7 +184,7 @@ class Item extends PureComponent {
|
|||||||
alt={description}
|
alt={description}
|
||||||
title={description}
|
title={description}
|
||||||
lang={lang}
|
lang={lang}
|
||||||
style={{ objectPosition: letterbox ? null : `${x}% ${y}%` }}
|
style={{ ...imageStyle, objectPosition: letterbox ? null : `${x}% ${y}%` }}
|
||||||
onLoad={this.handleImageLoad}
|
onLoad={this.handleImageLoad}
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
@@ -353,8 +355,6 @@ class MediaGallery extends PureComponent {
|
|||||||
|
|
||||||
if (this.isStandaloneEligible()) { // TODO: cropImages setting
|
if (this.isStandaloneEligible()) { // TODO: cropImages setting
|
||||||
style.aspectRatio = `${this.props.media.getIn([0, 'meta', 'small', 'aspect'])}`;
|
style.aspectRatio = `${this.props.media.getIn([0, 'meta', 'small', 'aspect'])}`;
|
||||||
} else {
|
|
||||||
style.aspectRatio = '16 / 9';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isStandaloneEligible()) {
|
if (this.isStandaloneEligible()) {
|
||||||
@@ -371,7 +371,7 @@ class MediaGallery extends PureComponent {
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
children = media.take(4).map((attachment, i) => (
|
children = media.map((attachment, i) => (
|
||||||
<Item
|
<Item
|
||||||
key={attachment.get('id')}
|
key={attachment.get('id')}
|
||||||
autoplay={autoplay}
|
autoplay={autoplay}
|
||||||
@@ -383,7 +383,9 @@ class MediaGallery extends PureComponent {
|
|||||||
letterbox={letterbox}
|
letterbox={letterbox}
|
||||||
displayWidth={width}
|
displayWidth={width}
|
||||||
visible={visible || uncached}
|
visible={visible || uncached}
|
||||||
useBlurhash={useBlurhash} />
|
useBlurhash={useBlurhash}
|
||||||
|
imageStyle={{ aspectRatio: '16 / 9' }}
|
||||||
|
/>
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user