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

@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React from "react";
import ListItemText from "@material-ui/core/ListItemText";
import { Button } from "@material-ui/core";
@@ -13,7 +13,6 @@ import Nui from "../../../os/nui-events/utils/Nui";
export const ContactList = () => {
const contacts = useContacts();
const [call, setCall] = useState("");
const startCall = (number) => {
console.log(number);
@@ -30,7 +30,7 @@ const useStyles = makeStyles((theme) => ({
},
}));
export const AddContactModal = ({ handleClose, show, children }) => {
export const AddContactModal = ({ handleClose, show }) => {
const [name, setName] = useState("");
const [number, setNumber] = useState("");
const classes = useStyles();
@@ -1,5 +1,4 @@
import React, { useState } from "react";
import { makeStyles } from "@material-ui/core/styles";
import { AppWrapper } from "../../../ui/components";
import { AppTitle } from "../../../ui/components/AppTitle";
import { AppContent } from "../../../ui/components/AppContent";
@@ -9,20 +8,8 @@ import AddCircleIcon from "@material-ui/icons/AddCircle";
import { AddContactModal } from "./ContactModal";
import { Button } from "@material-ui/core";
const useStyles = makeStyles((theme) => ({
modalOpener: {
backgroundColor: "red",
height: 50,
position: "fixed",
display: "flex",
justifyContent: "center",
alignItems: "center",
},
}));
export const ContactsApp = () => {
const [modal, setModal] = useState(false);
const classes = useStyles();
const contacts = useApp("CONTACTS");
const openModal = () => {
+11 -1
View File
@@ -1,7 +1,17 @@
import { useRecoilValue } from "recoil";
import { contactsState } from "./state";
export const useContacts = () => {
interface Contact {
id: string;
display: string;
number: string;
}
interface IUseContacts {
contacts: Contact[];
}
export const useContacts = (): IUseContacts => {
const contacts = useRecoilValue(contactsState.contacts);
return { contacts };
};
Whitespace-only changes.
View File
Whitespace-only changes.
@@ -1,10 +1,6 @@
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import {
Button,
Typography,
Paper,
} from "@material-ui/core";
import { Button, Typography, Paper } from "@material-ui/core";
import { ImageDisplay } from "../images/ImageDisplay";
import { ListItem } from "../../../../ui/components/ListItem";
import ChatIcon from "@material-ui/icons/Chat";
@@ -63,10 +59,10 @@ export const SelloutItem = (listing) => {
</Typography>
</div>
<ImageDisplay imgURL={listing.img} />
<Typography variant="h7" className={classes.desc}>
<Typography variant="h6" className={classes.desc}>
{listing.description}
</Typography>
<div className={classes.postActions}>
<div>
<Button>
<ChatIcon style={{ color: "#f44336" }} />
</Button>
@@ -1,9 +1,8 @@
import React from "react";
import Paper from "@material-ui/core/Paper";
import { makeStyles } from "@material-ui/core";
import LinkedInIcon from "@material-ui/icons/LinkedIn";
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faAd } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faAd } from "@fortawesome/free-solid-svg-icons";
const useStyles = makeStyles((theme) => ({
root: {
@@ -1,5 +1,11 @@
import React from 'react'
import React from "react";
export const ImageDisplay = ({ imgURL }) => {
return <img src={imgURL} alt="Image" style={{height: 200, width: 350, margin: "auto"}}/>
}
return (
<img
src={imgURL}
alt="twitter display"
style={{ height: 200, width: 350, margin: "auto" }}
/>
);
};
@@ -1,7 +1,14 @@
import React from "react";
import { ListItem, ListItemText, Divider } from "@material-ui/core";
export const SettingItem = ({ options, label, value, onClick }) => {
interface IProps {
options?: any;
label: string;
value: string | null;
onClick?: any;
}
export const SettingItem = ({ options, label, value, onClick }: IProps) => {
return (
<>
<ListItem onClick={() => onClick(options)} button>
+1 -1
View File
@@ -8,7 +8,7 @@ const settingsState = atom({
default: Default,
});
export const useSettings = () => {
export const useSettings = (): any => {
const [settings, setSettings] = useConfig(settingsState);
const [config] = useConfig();
const currentTheme = () => createMuiTheme(config.themes[settings.theme]);
@@ -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(
+1 -1
View File
@@ -3,7 +3,7 @@ import { atom } from "recoil";
export const twitterState = {
profile: atom({
key: "profile",
default: null,
default: {},
}),
tweets: atom({
key: "tweets",
+16 -1
View File
@@ -1,7 +1,22 @@
import { useRecoilValue, useRecoilState } from "recoil";
import { twitterState } from "./state";
export const useProfile = () => {
interface IProfile {
profile_name?: string;
bio?: string;
job?: string;
location?: string;
avatar_url?: string;
}
interface IUseProfile {
profile: IProfile;
updateProfileLoading: any;
updateProfileSuccessful: any;
setUpdateProfileSuccessful: any;
}
export const useProfile = (): IUseProfile => {
const profile = useRecoilValue(twitterState.profile);
const updateProfileLoading = useRecoilValue(
twitterState.updateProfileLoading
+1 -1
View File
@@ -1,4 +1,4 @@
import { useRecoilValue, useSetRecoilState } from "recoil";
import { useRecoilValue } from "recoil";
import { twitterState } from "./state";
export const useTweets = () => {