kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Instead of str.replaceAll, use str.replace with regex (for better browser support)
rodzic
1db4cd60d4
commit
135ec190ee
|
@ -108,6 +108,7 @@ export default class ScrollableList extends PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps, prevState, snapshot) {
|
componentDidUpdate(prevProps, prevState, snapshot) {
|
||||||
|
console.log(snapshot);
|
||||||
// Reset the scroll position when a new child comes in in order not to
|
// Reset the scroll position when a new child comes in in order not to
|
||||||
// jerk the scrollbar around if you're already scrolled down the page.
|
// jerk the scrollbar around if you're already scrolled down the page.
|
||||||
if (snapshot !== null) {
|
if (snapshot !== null) {
|
||||||
|
@ -260,7 +261,7 @@ export default class ScrollableList extends PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderFeed = () => {
|
renderFeed = () => {
|
||||||
const { children, scrollKey, isLoading, hasMore, prepend, onLoadMore } = this.props;
|
const { children, scrollKey, isLoading, hasMore, prepend, onLoadMore, placeholderComponent: Placeholder, placeholderCount } = this.props;
|
||||||
const childrenCount = React.Children.count(children);
|
const childrenCount = React.Children.count(children);
|
||||||
const trackScroll = true; //placeholder
|
const trackScroll = true; //placeholder
|
||||||
const loadMore = (hasMore && onLoadMore) ? <LoadMore visible={!isLoading} onClick={this.handleLoadMore} /> : null;
|
const loadMore = (hasMore && onLoadMore) ? <LoadMore visible={!isLoading} onClick={this.handleLoadMore} /> : null;
|
||||||
|
@ -287,6 +288,11 @@ export default class ScrollableList extends PureComponent {
|
||||||
})}
|
})}
|
||||||
</IntersectionObserverArticleContainer>
|
</IntersectionObserverArticleContainer>
|
||||||
))}
|
))}
|
||||||
|
{(isLoading && Placeholder && placeholderCount > 0) && (
|
||||||
|
Array(placeholderCount).fill().map((_, i) => (
|
||||||
|
<Placeholder key={i} />
|
||||||
|
))
|
||||||
|
)}
|
||||||
{this.getMoreFollows()}
|
{this.getMoreFollows()}
|
||||||
{loadMore}
|
{loadMore}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -14,7 +14,7 @@ export const buildStatus = (state, scheduledStatus) => {
|
||||||
application: null,
|
application: null,
|
||||||
bookmarked: false,
|
bookmarked: false,
|
||||||
card: null,
|
card: null,
|
||||||
content: params.get('text', '').replaceAll('\n', '<br>'),
|
content: params.get('text', '').replace(new RegExp('\n', 'g'), '<br>'), /* eslint-disable-line no-control-regex */
|
||||||
created_at: params.get('scheduled_at'),
|
created_at: params.get('scheduled_at'),
|
||||||
emojis: [],
|
emojis: [],
|
||||||
favourited: false,
|
favourited: false,
|
||||||
|
|
|
@ -13,7 +13,7 @@ export const buildStatus = (state, pendingStatus, idempotencyKey) => {
|
||||||
application: null,
|
application: null,
|
||||||
bookmarked: false,
|
bookmarked: false,
|
||||||
card: null,
|
card: null,
|
||||||
content: pendingStatus.get('status', '').replaceAll('\n', '<br>'),
|
content: pendingStatus.get('status', '').replace(new RegExp('\n', 'g'), '<br>'), /* eslint-disable-line no-control-regex */
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
emojis: [],
|
emojis: [],
|
||||||
favourited: false,
|
favourited: false,
|
||||||
|
|
|
@ -9,7 +9,7 @@ export const onlyEmoji = (node, limit = 1, ignoreMentions = true) => {
|
||||||
node.querySelectorAll('a.mention').forEach(m => m.parentNode.removeChild(m));
|
node.querySelectorAll('a.mention').forEach(m => m.parentNode.removeChild(m));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.textContent.replaceAll(' ', '') !== '') return false;
|
if (node.textContent.replace(new RegExp(' ', 'g'), '') !== '') return false;
|
||||||
const emojis = Array.from(node.querySelectorAll('img.emojione'));
|
const emojis = Array.from(node.querySelectorAll('img.emojione'));
|
||||||
if (emojis.length === 0) return false;
|
if (emojis.length === 0) return false;
|
||||||
if (emojis.length > limit) return false;
|
if (emojis.length > limit) return false;
|
||||||
|
@ -17,7 +17,6 @@ export const onlyEmoji = (node, limit = 1, ignoreMentions = true) => {
|
||||||
if (images.length > emojis.length) return false;
|
if (images.length > emojis.length) return false;
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Apparently some browsers can't handle `node.textContent.replaceAll`??
|
|
||||||
// If anything in here crashes, skipping it is inconsequential.
|
// If anything in here crashes, skipping it is inconsequential.
|
||||||
console.error(e);
|
console.error(e);
|
||||||
return false;
|
return false;
|
||||||
|
|
Ładowanie…
Reference in New Issue