Instead of str.replaceAll, use str.replace with regex (for better browser support)

merge-requests/788/head
Alex Gleason 2021-10-12 10:31:15 -05:00
rodzic 1db4cd60d4
commit 135ec190ee
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
4 zmienionych plików z 10 dodań i 5 usunięć

Wyświetl plik

@ -108,6 +108,7 @@ export default class ScrollableList extends PureComponent {
}
componentDidUpdate(prevProps, prevState, snapshot) {
console.log(snapshot);
// 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.
if (snapshot !== null) {
@ -260,7 +261,7 @@ export default class ScrollableList extends PureComponent {
}
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 trackScroll = true; //placeholder
const loadMore = (hasMore && onLoadMore) ? <LoadMore visible={!isLoading} onClick={this.handleLoadMore} /> : null;
@ -287,6 +288,11 @@ export default class ScrollableList extends PureComponent {
})}
</IntersectionObserverArticleContainer>
))}
{(isLoading && Placeholder && placeholderCount > 0) && (
Array(placeholderCount).fill().map((_, i) => (
<Placeholder key={i} />
))
)}
{this.getMoreFollows()}
{loadMore}
</div>

Wyświetl plik

@ -14,7 +14,7 @@ export const buildStatus = (state, scheduledStatus) => {
application: null,
bookmarked: false,
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'),
emojis: [],
favourited: false,

Wyświetl plik

@ -13,7 +13,7 @@ export const buildStatus = (state, pendingStatus, idempotencyKey) => {
application: null,
bookmarked: false,
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(),
emojis: [],
favourited: false,

Wyświetl plik

@ -9,7 +9,7 @@ export const onlyEmoji = (node, limit = 1, ignoreMentions = true) => {
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'));
if (emojis.length === 0) 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;
return true;
} catch (e) {
// Apparently some browsers can't handle `node.textContent.replaceAll`??
// If anything in here crashes, skipping it is inconsequential.
console.error(e);
return false;