Merge branch 'cleanup' into 'develop'

Use Array.includes instead of indexOf

See merge request soapbox-pub/soapbox-fe!1727
environments/review-develop-3zknud/deployments/774
marcin mikołajczak 2022-08-12 22:07:19 +00:00
commit 67f5f5fb8b
11 zmienionych plików z 16 dodań i 16 usunięć

Wyświetl plik

@ -37,7 +37,7 @@ if (!HTMLCanvasElement.prototype.toBlob) {
const dataURL = this.toDataURL(type, quality);
let data;
if (dataURL.indexOf(BASE64_MARKER) >= 0) {
if (dataURL.includes(BASE64_MARKER)) {
const [, base64] = dataURL.split(BASE64_MARKER);
data = decodeBase64(base64);
} else {

Wyświetl plik

@ -30,7 +30,7 @@ const textAtCursorMatchesToken = (str: string, caretPosition: number, searchToke
word = str.slice(left, right + caretPosition);
}
if (!word || word.trim().length < 3 || searchTokens.indexOf(word[0]) === -1) {
if (!word || word.trim().length < 3 || !searchTokens.includes(word[0])) {
return [null, null];
}

Wyświetl plik

@ -23,7 +23,7 @@ const textAtCursorMatchesToken = (str: string, caretPosition: number) => {
word = str.slice(left, right + caretPosition);
}
if (!word || word.trim().length < 3 || ['@', ':', '#'].indexOf(word[0]) === -1) {
if (!word || word.trim().length < 3 || !['@', ':', '#'].includes(word[0])) {
return [null, null];
}

Wyświetl plik

@ -38,7 +38,7 @@ const MediaItem: React.FC<IMediaItem> = ({ attachment, displayWidth, onOpenMedia
};
const hoverToPlay = () => {
return !autoPlayGif && ['gifv', 'video'].indexOf(attachment.type) !== -1;
return !autoPlayGif && ['gifv', 'video'].includes(attachment.type);
};
const handleClick: React.MouseEventHandler = e => {

Wyświetl plik

@ -85,8 +85,8 @@ export function search(value, { emojisToShowFilter, maxResults, include, exclude
pool = {};
data.categories.forEach(category => {
const isIncluded = include && include.length ? include.indexOf(category.name.toLowerCase()) > -1 : true;
const isExcluded = exclude && exclude.length ? exclude.indexOf(category.name.toLowerCase()) > -1 : false;
const isIncluded = include && include.length ? include.includes(category.name.toLowerCase()) : true;
const isExcluded = exclude && exclude.length ? exclude.includes(category.name.toLowerCase()) : false;
if (!isIncluded || isExcluded) {
return;
}
@ -95,8 +95,8 @@ export function search(value, { emojisToShowFilter, maxResults, include, exclude
});
if (custom.length) {
const customIsIncluded = include && include.length ? include.indexOf('custom') > -1 : true;
const customIsExcluded = exclude && exclude.length ? exclude.indexOf('custom') > -1 : false;
const customIsIncluded = include && include.length ? include.includes('custom') : true;
const customIsExcluded = exclude && exclude.length ? exclude.includes('custom') : false;
if (customIsIncluded && !customIsExcluded) {
addCustomToPool(custom, pool);
}

Wyświetl plik

@ -15,7 +15,7 @@ const buildSearch = (data) => {
(split ? string.split(/[-|_|\s]+/) : [string]).forEach((s) => {
s = s.toLowerCase();
if (search.indexOf(s) === -1) {
if (!search.includes(s)) {
search.push(s);
}
});
@ -190,7 +190,7 @@ function getData(emoji, skin, set) {
function uniq(arr) {
return arr.reduce((acc, item) => {
if (acc.indexOf(item) === -1) {
if (!acc.includes(item)) {
acc.push(item);
}
return acc;
@ -201,7 +201,7 @@ function intersect(a, b) {
const uniqA = uniq(a);
const uniqB = uniq(b);
return uniqA.filter(item => uniqB.indexOf(item) >= 0);
return uniqA.filter(item => uniqB.includes(item));
}
function deepMerge(a, b) {

Wyświetl plik

@ -26,7 +26,7 @@ const addAutoPlay = (html: string): string => {
const iframe = document.querySelector('iframe');
if (iframe) {
if (iframe.src.indexOf('?') !== -1) {
if (iframe.src.includes('?')) {
iframe.src += '&';
} else {
iframe.src += '?';

Wyświetl plik

@ -92,7 +92,7 @@ export default class ModalRoot extends React.PureComponent {
}
renderLoading = modalId => () => {
return ['MEDIA', 'VIDEO', 'BOOST', 'CONFIRM', 'ACTIONS'].indexOf(modalId) === -1 ? <ModalLoading /> : null;
return !['MEDIA', 'VIDEO', 'BOOST', 'CONFIRM', 'ACTIONS'].includes(modalId) ? <ModalLoading /> : null;
}
renderError = (props) => {

Wyświetl plik

@ -28,7 +28,7 @@ const UserPanel: React.FC<IUserPanel> = ({ accountId, action, badges, domain })
if (!account) return null;
const displayNameHtml = { __html: account.get('display_name_html') };
const acct = account.get('acct').indexOf('@') === -1 && domain ? `${account.get('acct')}@${domain}` : account.get('acct');
const acct = !account.get('acct').includes('@') && domain ? `${account.get('acct')}@${domain}` : account.get('acct');
const header = account.get('header');
const verified = account.get('verified');

Wyświetl plik

@ -352,7 +352,7 @@ const UI: React.FC = ({ children }) => {
const handleDragEnter = (e: DragEvent) => {
e.preventDefault();
if (e.target && dragTargets.current.indexOf(e.target) === -1) {
if (e.target && !dragTargets.current.includes(e.target)) {
dragTargets.current.push(e.target);
}

Wyświetl plik

@ -93,7 +93,7 @@ const toServerSideType = (columnType: string): string => {
case 'thread':
return columnType;
default:
if (columnType.indexOf('list:') > -1) {
if (columnType.includes('list:')) {
return 'home';
} else {
return 'public'; // community, account, hashtag