lint fixes

This commit is contained in:
ewwwwwwww 2022-06-29 01:25:57 -07:00
parent f8bd30a5f7
commit 89bba0e2e3
2 changed files with 34 additions and 35 deletions

View file

@ -1,18 +1,19 @@
import classNames from 'classnames'; import classNames from 'classnames';
import React, { useRef, useEffect, useState } from 'react';
import { usePopper } from 'react-popper';
import { defineMessages, useIntl } from 'react-intl';
import { createPortal } from 'react-dom';
import { supportsPassiveEvents } from 'detect-passive-events'; import { supportsPassiveEvents } from 'detect-passive-events';
import React, { useEffect, useState } from 'react';
import { createPortal } from 'react-dom';
import { defineMessages, useIntl } from 'react-intl';
import { usePopper } from 'react-popper';
import { IconButton, Toggle } from 'soapbox/components/ui'; import { IconButton } from 'soapbox/components/ui';
import { useSettings, useSystemTheme } from 'soapbox/hooks'; import { useSettings } from 'soapbox/hooks';
import type { List } from 'immutable';
import { buildCustomEmojis } from '../../emoji/emoji'; import { buildCustomEmojis } from '../../emoji/emoji';
import { EmojiPicker as EmojiPickerAsync } from '../../ui/util/async-components'; import { EmojiPicker as EmojiPickerAsync } from '../../ui/util/async-components';
// import EmojiPicker from '../../emoji/emoji_picker'; // import EmojiPicker from '../../emoji/emoji_picker';
import type { List } from 'immutable';
let EmojiPicker: any; // load asynchronously let EmojiPicker: any; // load asynchronously
const messages = defineMessages({ const messages = defineMessages({
@ -33,8 +34,8 @@ const messages = defineMessages({
}); });
interface IEmojiPickerDropdown { interface IEmojiPickerDropdown {
custom_emojis: any, custom_emojis: List<any>,
frequentlyUsedEmojis: string[], frequentlyUsedEmojis: string[],
intl: any, intl: any,
onPickEmoji: (emoji: any) => void, onPickEmoji: (emoji: any) => void,
onSkinTone: () => void, onSkinTone: () => void,
@ -65,15 +66,11 @@ const EmojiPickerDropdown: React.FC<IEmojiPickerDropdown> = ({ custom_emojis, fr
setVisible(!visible); setVisible(!visible);
}; };
const handleHide = () => {
setVisible(false);
};
const handleDocClick = (e: any) => { const handleDocClick = (e: any) => {
if (!containerElement?.contains(e.target) && !popperElement?.contains(e.target)) { if (!containerElement?.contains(e.target) && !popperElement?.contains(e.target)) {
setVisible(false); setVisible(false);
} }
} };
const handlePick = (emoji: any) => { const handlePick = (emoji: any) => {
if (!emoji.native) { if (!emoji.native) {
@ -82,7 +79,7 @@ const EmojiPickerDropdown: React.FC<IEmojiPickerDropdown> = ({ custom_emojis, fr
setVisible(false); setVisible(false);
onPickEmoji(emoji); onPickEmoji(emoji);
} };
const getI18n = () => { const getI18n = () => {
return { return {
@ -111,7 +108,7 @@ const EmojiPickerDropdown: React.FC<IEmojiPickerDropdown> = ({ custom_emojis, fr
return function cleanup() { return function cleanup() {
document.removeEventListener('click', handleDocClick); document.removeEventListener('click', handleDocClick);
document.removeEventListener('touchend', handleDocClick); document.removeEventListener('touchend', handleDocClick);
} };
}); });
useEffect(() => { useEffect(() => {
@ -133,21 +130,23 @@ const EmojiPickerDropdown: React.FC<IEmojiPickerDropdown> = ({ custom_emojis, fr
if (loading) { if (loading) {
Popup = () => <div />; Popup = () => <div />;
} else { } else {
Popup = () => <div> Popup = () => (
<EmojiPicker <div>
custom={[{ emojis: buildCustomEmojis(custom_emojis) }]} <EmojiPicker
title={title} custom={[{ emojis: buildCustomEmojis(custom_emojis) }]}
onEmojiSelect={handlePick} title={title}
recent={frequentlyUsedEmojis} onEmojiSelect={handlePick}
perLine={8} recent={frequentlyUsedEmojis}
skin={onSkinTone} perLine={8}
emojiSize={38} skin={onSkinTone}
emojiButtonSize={50} emojiSize={38}
set={'twitter'} emojiButtonSize={50}
theme={theme} set={'twitter'}
autoFocus theme={theme}
/> autoFocus
</div> />
</div>
);
} }
return ( return (
@ -179,7 +178,7 @@ const EmojiPickerDropdown: React.FC<IEmojiPickerDropdown> = ({ custom_emojis, fr
> >
{visible && (<Popup />)} {visible && (<Popup />)}
</div>, </div>,
document.body document.body,
)} )}
</div> </div>
); );

View file

@ -1,4 +1,4 @@
import data from '@emoji-mart/data/sets/14/twitter.json' import data from '@emoji-mart/data/sets/14/twitter.json';
import { Picker as EmojiPicker, PickerProps } from 'emoji-mart'; import { Picker as EmojiPicker, PickerProps } from 'emoji-mart';
import React, { useRef, useEffect } from 'react'; import React, { useRef, useEffect } from 'react';
@ -29,5 +29,5 @@ function Picker(props: PickerProps) {
} }
export { export {
Picker Picker,
} };