Fix loading on older browsers (#397)

This commit is contained in:
Nitan Alexandru Marcel 2022-03-18 03:36:48 +00:00 committed by GitHub
parent 13248962af
commit a2655ee6a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View file

@ -88,7 +88,7 @@ function SpaceAddExistingContent({ roomId }) {
}; };
const handleSearch = (ev) => { const handleSearch = (ev) => {
const term = ev.target.value.toLocaleLowerCase().replaceAll(' ', ''); const term = ev.target.value.toLocaleLowerCase().replace(/\s/g, '');
if (term === '') { if (term === '') {
setSearchIds(null); setSearchIds(null);
return; return;
@ -100,7 +100,7 @@ function SpaceAddExistingContent({ roomId }) {
if (!name) return false; if (!name) return false;
name = name.normalize('NFKC') name = name.normalize('NFKC')
.toLocaleLowerCase() .toLocaleLowerCase()
.replaceAll(' ', ''); .replace(/\s/g, '');
return name.includes(term); return name.includes(term);
}); });
setSearchIds(searchedIds); setSearchIds(searchedIds);

View file

@ -97,13 +97,13 @@ function getFormattedBody(markdown) {
function getReplyFormattedBody(roomId, reply) { function getReplyFormattedBody(roomId, reply) {
const replyToLink = `<a href="https://matrix.to/#/${roomId}/${reply.eventId}">In reply to</a>`; const replyToLink = `<a href="https://matrix.to/#/${roomId}/${reply.eventId}">In reply to</a>`;
const userLink = `<a href="https://matrix.to/#/${reply.userId}">${reply.userId}</a>`; const userLink = `<a href="https://matrix.to/#/${reply.userId}">${reply.userId}</a>`;
const formattedReply = getFormattedBody(reply.body.replaceAll('\n', '\n> ')); const formattedReply = getFormattedBody(reply.body.replace(/\n/g, '\n> '));
return `<mx-reply><blockquote>${replyToLink}${userLink}<br />${formattedReply}</blockquote></mx-reply>`; return `<mx-reply><blockquote>${replyToLink}${userLink}<br />${formattedReply}</blockquote></mx-reply>`;
} }
function bindReplyToContent(roomId, reply, content) { function bindReplyToContent(roomId, reply, content) {
const newContent = { ...content }; const newContent = { ...content };
newContent.body = `> <${reply.userId}> ${reply.body.replaceAll('\n', '\n> ')}`; newContent.body = `> <${reply.userId}> ${reply.body.replace(/\n/g, '\n> ')}`;
newContent.body += `\n\n${content.body}`; newContent.body += `\n\n${content.body}`;
newContent.format = 'org.matrix.custom.html'; newContent.format = 'org.matrix.custom.html';
newContent['m.relates_to'] = content['m.relates_to'] || {}; newContent['m.relates_to'] = content['m.relates_to'] || {};

View file

@ -123,7 +123,7 @@ class AsyncSearch extends EventEmitter {
_normalize(item) { _normalize(item) {
let myItem = item.normalize(this.normalizeUnicode ? 'NFKC' : 'NFC'); let myItem = item.normalize(this.normalizeUnicode ? 'NFKC' : 'NFC');
if (!this.isCaseSensitive) myItem = myItem.toLocaleLowerCase(); if (!this.isCaseSensitive) myItem = myItem.toLocaleLowerCase();
if (this.ignoreWhitespace) myItem = myItem.replaceAll(' ', ''); if (this.ignoreWhitespace) myItem = myItem.replace(/\s/g, '');
return myItem; return myItem;
} }