working typescript compiling and fixing linting issues

This commit is contained in:
erik-sn committed 2020-10-11 13:59:25 -04:00
1 parent b1babd88c2
commit 3273d192c9
49 files changed
+271 -110

No files matched your search

@@ -52,6 +52,11 @@ const useStyles = makeStyles((theme) => ({
},
}));
interface Image {
id: string;
link: string;
}
export const AddTweetModal = () => {
const classes = useStyles();
const { message, setMessage, modalVisible, setModalVisible } = useModal();
@@ -61,10 +66,10 @@ export const AddTweetModal = () => {
const [showImagePrompt, setShowImagePrompt] = useState(false);
const [link, setLink] = useState("");
const [images, setImages] = useState([]);
const [images, setImages] = useState<Image[]>([]);
const reset = () => {
setShowImagePrompt(null);
setShowImagePrompt(false);
setShowEmoji(false);
setLink("");
@@ -79,16 +84,18 @@ export const AddTweetModal = () => {
// when the user presses escape we should close the modal
const _handleEscape = (e) => {
const isEscapeKey = e.key == "Escape" || e.key == "Esc";
const isEscapeKey = e.key === "Escape" || e.key === "Esc";
if (isEscapeKey) {
e.preventDefault();
_handleClose();
}
};
useEffect(() => {
const listener = window.addEventListener("keydown", _handleEscape, true);
return () => window.removeEventListener("keydown", listener);
}, []);
window.addEventListener("keydown", _handleEscape, true);
return () => window.removeEventListener("keydown", _handleEscape);
});
if (!config) return null;
const submitTweet = () => {
const cleanedMessage = message.trim();
@@ -140,7 +147,7 @@ export const AddTweetModal = () => {
const toggleShowEmoji = () => {
// clear the images so we can seemlessly toggle between emoji/images
setShowImagePrompt(false);
setImages("");
setImages([]);
setShowEmoji(!showEmoji);
};
+1 -1
View File
@@ -30,7 +30,7 @@ function Avatar({ avatarUrl, showInvalidImage, height, width }) {
<img
className={classes.img}
src={showInvalidImage ? IMG_INVALID_AVATAR : IMG_DEFAULT_AVATAR}
alt="Invalid avatar image"
alt="Invalid avatar"
style={{ height, width }}
/>
)}
@@ -69,7 +69,7 @@ export const TwitterApp = () => {
return (
<AppWrapper id="twitter-app">
<AddTweetModal />
<div className={modalVisible ? classes.backgroundModal : null} />
<div className={modalVisible ? classes.backgroundModal : undefined} />
<TwitterTitle />
<AppContent>
{promptProfileName ? (
@@ -24,7 +24,7 @@ function TwitterSearch() {
const classes = useStyles();
const { t } = useTranslation();
const [searchValue, setSearchValue] = useState("");
const { tweets, setTweets } = useFilteredTweets();
const { tweets } = useFilteredTweets();
const handleChange = (e) => setSearchValue(e.target.value);
@@ -35,6 +35,8 @@ function TwitterSearch() {
Nui.send("phone:fetchTweetsFiltered", cleanedSearchValue);
};
const filteredTweets = tweets || [];
return (
<>
<div className={classes.root}>
@@ -49,7 +51,7 @@ function TwitterSearch() {
inputRef={(input) => input && input.focus()}
/>
</div>
{tweets && tweets.length > 0 && <TweetList tweets={tweets} />}
{filteredTweets.length > 0 && <TweetList tweets={tweets} />}
</div>
<SearchButton handleClick={handleSubmit} />
</>
@@ -21,8 +21,8 @@ export default function AlertBar() {
const { t } = useTranslation();
const { updateProfileSuccessful, setUpdateProfileSuccessful } = useProfile();
const { createTweetSuccessful, setCreateTweetSuccessful } = useTweetStatus();
const [severity, setSeverity] = useState(null);
const [open, setOpen] = useState(null);
const [severity, setSeverity] = useState<string | null>(null);
const [open, setOpen] = useState(false);
const [message, setMessage] = useState(null);
const handleClose = () => {
@@ -49,7 +49,7 @@ export default function AlertBar() {
setSeverity("error");
setMessage(t("APPS_TWITTER_EDIT_PROFILE_FAILURE"));
}
}, [updateProfileSuccessful, createTweetSuccessful]);
}, [updateProfileSuccessful, createTweetSuccessful, t]);
return (
<Snackbar
@@ -49,7 +49,11 @@ export const Image = ({ link, handleClick, small }) => {
<CloseIcon />
</IconButton>
)}
<img className={small ? classes.imgSmall : classes.img} src={link} />
<img
alt="small avatar"
className={small ? classes.imgSmall : classes.img}
src={link}
/>
</div>
);
};
@@ -23,6 +23,7 @@ export function ProfilePrompt() {
const classes = useStyles();
const { t } = useTranslation();
const { profile } = useProfile();
const [name, handleNameChange] = useState(profile.profile_name || "");
const handleUpdate = () => {
@@ -7,7 +7,6 @@ import {
Button,
Typography,
} from "@material-ui/core";
import FavoriteBorderIcon from "@material-ui/icons/FavoriteBorder";
import MoreIcon from "@material-ui/icons/MoreVert";
import { ListItem } from "../../../../ui/components/ListItem";
@@ -1,4 +1,4 @@
import React, { useEffect, useRef } from "react";
import React from "react";
import { useTranslation } from "react-i18next";
import { makeStyles } from "@material-ui/core/styles";
import { TextField } from "@material-ui/core";
@@ -23,6 +23,8 @@ export const TweetMessage = ({ message, handleChange }) => {
const { config } = usePhone();
const { t } = useTranslation();
if (!config) return null;
const overCharacterLimit =
message.trim().length > config.twitter.characterLimit;
const characterWarningPrompt = `${t(