mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-05 06:28:51 +00:00
working images in the database
This commit is contained in:
1 parent
997f550aab
commit
9e40fb8010
15 files changed
+150
-121
No files matched your search
@@ -6,12 +6,12 @@ import CloseIcon from "@material-ui/icons/Close";
|
|||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
|
|
||||||
import Nui from "../../../os/nui-events/utils/Nui";
|
import Nui from "../../../os/nui-events/utils/Nui";
|
||||||
import types from "../types";
|
import { IMAGE_DELIMITER } from "../utils/images";
|
||||||
import { withValidMedia } from "../utils/media";
|
import { withValidImage } from "../utils/images";
|
||||||
import "./emoji.css";
|
import "./emoji.css";
|
||||||
import EmojiSelect from "./EmojiSelect";
|
import EmojiSelect from "./EmojiSelect";
|
||||||
import MediaDisplay from "./MediaDisplay";
|
import ImageDisplay from "./ImageDisplay";
|
||||||
import MediaPrompt from "./MediaPrompt";
|
import ImagePrompt from "./ImagePrompt";
|
||||||
import TweetText from "./TweetText";
|
import TweetText from "./TweetText";
|
||||||
import ControlButtons from "./ControlButtons";
|
import ControlButtons from "./ControlButtons";
|
||||||
import IconButtons from "./IconButtons";
|
import IconButtons from "./IconButtons";
|
||||||
@@ -61,21 +61,27 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const IMAGES = [
|
||||||
|
"https://assets.simpleviewinc.com/simpleview/image/upload/c_limit,h_1200,q_75,w_1200/v1/clients/boston/c07044da_9483_4fd5_8e37_5b75513dcc80_6b058b6f-7bdc-4f11-b217-4561c07901f3.jpg",
|
||||||
|
"https://www.hiusa.org/wp-content/uploads/2020/04/Aerial-View-Boston-Osman-Rana-Unsplash-1000x550-compressor-778x446.jpg",
|
||||||
|
"https://www.mccarter.com/wp-content/uploads/2019/10/Location-Boston.png",
|
||||||
|
];
|
||||||
|
|
||||||
export const AddTweetModal = ({ visible, handleClose }) => {
|
export const AddTweetModal = ({ visible, handleClose }) => {
|
||||||
const [showEmoji, setShowEmoji] = useState(false);
|
const [showEmoji, setShowEmoji] = useState(false);
|
||||||
|
const [showImagePrompt, setShowImagePrompt] = useState(false);
|
||||||
|
const [image, setimage] = useState("");
|
||||||
|
|
||||||
const [text, setText] = useState("");
|
const [text, setText] = useState("");
|
||||||
const [media, setMedia] = useState([]);
|
const [images, setImages] = useState(IMAGES);
|
||||||
const [mediaType, setMediaType] = useState(null);
|
|
||||||
const [mediaLink, setMediaLink] = useState(null);
|
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
const reset = useCallback(() => {
|
const reset = useCallback(() => {
|
||||||
setMediaType(null);
|
setShowImagePrompt(null);
|
||||||
setMediaLink(null);
|
|
||||||
setShowEmoji(false);
|
setShowEmoji(false);
|
||||||
setMedia([]);
|
|
||||||
|
setimage("");
|
||||||
|
setImages([]);
|
||||||
setText("");
|
setText("");
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -103,41 +109,37 @@ export const AddTweetModal = ({ visible, handleClose }) => {
|
|||||||
: classes.displayNone;
|
: classes.displayNone;
|
||||||
|
|
||||||
const submitTweet = () => {
|
const submitTweet = () => {
|
||||||
const data = { message: text, media, realUser: "testUser" };
|
const data = {
|
||||||
|
message: text,
|
||||||
|
images: images.join(IMAGE_DELIMITER),
|
||||||
|
realUser: "testUser",
|
||||||
|
};
|
||||||
Nui.send("phone:createTweet", data);
|
Nui.send("phone:createTweet", data);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTextChange = (e) => setText(e.target.value);
|
const handleTextChange = (e) => setText(e.target.value);
|
||||||
|
|
||||||
const addMedia = () => {
|
const addImage = () => {
|
||||||
setMediaType(null);
|
withValidImage(image, () => setImages([...images, image]));
|
||||||
setMediaLink(null);
|
|
||||||
|
|
||||||
withValidMedia(mediaLink, () =>
|
setShowImagePrompt(false);
|
||||||
setMedia(media.concat([{ id: uuidv4(), mediaType, mediaLink }]))
|
setimage("");
|
||||||
);
|
|
||||||
};
|
};
|
||||||
const removeMedia = (id) => setMedia(media.filter((m) => m.id !== id));
|
const removeImage = (image) => setImages(images.filter((i) => i !== image));
|
||||||
const handleMediaChange = (e) => setMediaLink(e.target.value);
|
const handleimageChange = (e) => setimage(e.target.value);
|
||||||
const setMediaTypeImage = () => {
|
const toggleShowImagePrompt = () => {
|
||||||
setShowEmoji(false); // clear the emoji so we can switch between emoji/media
|
setShowEmoji(false); // clear the emoji so we can switch between emoji/images
|
||||||
setMediaType(types.IMAGE);
|
setShowImagePrompt(!showImagePrompt);
|
||||||
};
|
};
|
||||||
const closeMediaPrompt = () => {
|
|
||||||
setMediaType(null);
|
|
||||||
setMediaLink(null);
|
|
||||||
};
|
|
||||||
|
|
||||||
const toggleShowEmoji = () => {
|
const toggleShowEmoji = () => {
|
||||||
// clear the media items so we can seemlessly toggle between emoji/media
|
// clear the images so we can seemlessly toggle between emoji/images
|
||||||
setMediaType(null);
|
setShowImagePrompt(false);
|
||||||
setMediaLink(null);
|
setImages("");
|
||||||
setShowEmoji(!showEmoji);
|
setShowEmoji(!showEmoji);
|
||||||
};
|
};
|
||||||
const handleEmojiClick = (emojiObject, e) => {
|
const handleEmojiClick = (emojiObject, e) => {
|
||||||
setText(text.concat(emojiObject.native));
|
setText(text.concat(emojiObject.native));
|
||||||
};
|
};
|
||||||
const mediaPromptVisible = mediaType && !showEmoji;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={showHideClassName}>
|
<div className={showHideClassName}>
|
||||||
@@ -147,27 +149,27 @@ export const AddTweetModal = ({ visible, handleClose }) => {
|
|||||||
</Button>
|
</Button>
|
||||||
<TweetText text={text} handleChange={handleTextChange} />
|
<TweetText text={text} handleChange={handleTextChange} />
|
||||||
<AddTweetStatus />
|
<AddTweetStatus />
|
||||||
<MediaPrompt
|
<ImagePrompt
|
||||||
visible={mediaPromptVisible}
|
visible={showImagePrompt}
|
||||||
value={mediaLink}
|
value={image}
|
||||||
handleChange={handleMediaChange}
|
handleChange={handleimageChange}
|
||||||
/>
|
/>
|
||||||
<EmojiSelect visible={showEmoji} onEmojiClick={handleEmojiClick} />
|
<EmojiSelect visible={showEmoji} onEmojiClick={handleEmojiClick} />
|
||||||
<MediaDisplay
|
<ImageDisplay
|
||||||
visible={!showEmoji}
|
visible={!showEmoji && images.length > 0}
|
||||||
media={media}
|
images={images}
|
||||||
removeMedia={removeMedia}
|
removeImage={removeImage}
|
||||||
/>
|
/>
|
||||||
<div className={classes.buttonsContainer}>
|
<div className={classes.buttonsContainer}>
|
||||||
<IconButtons
|
<IconButtons
|
||||||
onMediaClick={mediaType ? closeMediaPrompt : setMediaTypeImage}
|
onImageClick={toggleShowImagePrompt}
|
||||||
onEmojiClick={toggleShowEmoji}
|
onEmojiClick={toggleShowEmoji}
|
||||||
/>
|
/>
|
||||||
<ControlButtons
|
<ControlButtons
|
||||||
mediaType={mediaType}
|
showImagePrompt={showImagePrompt}
|
||||||
showEmoji={showEmoji}
|
showEmoji={showEmoji}
|
||||||
onPrimaryClick={mediaType ? addMedia : submitTweet}
|
onPrimaryClick={showImagePrompt ? addImage : submitTweet}
|
||||||
onCloseClick={showEmoji ? toggleShowEmoji : closeMediaPrompt}
|
onCloseClick={showEmoji ? toggleShowEmoji : toggleShowImagePrompt}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Paper>
|
</Paper>
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
alignItems: "justify-content",
|
alignItems: "justify-content",
|
||||||
marginRight: "15px",
|
marginRight: "15px",
|
||||||
},
|
},
|
||||||
closeMedia: {
|
close: {
|
||||||
marginLeft: "8px",
|
marginLeft: "8px",
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const ControlButtons = ({
|
export const ControlButtons = ({
|
||||||
mediaType,
|
showImagePrompt,
|
||||||
showEmoji,
|
showEmoji,
|
||||||
onCloseClick,
|
onCloseClick,
|
||||||
onPrimaryClick,
|
onPrimaryClick,
|
||||||
@@ -29,11 +29,11 @@ export const ControlButtons = ({
|
|||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const mediaPromptVisible = mediaType && !showEmoji;
|
const imagePromptVisible = showImagePrompt && !showEmoji;
|
||||||
const primaryButtonText = mediaPromptVisible
|
const primaryButtonText = imagePromptVisible
|
||||||
? t("APPS_TWITTER_SUBMIT_MEDIA")
|
? t("APPS_TWITTER_SUBMIT_IMAGE")
|
||||||
: t("APPS_TWITTER_TWEET");
|
: t("APPS_TWITTER_TWEET");
|
||||||
const showCloseButton = mediaType || showEmoji;
|
const showCloseButton = showImagePrompt || showEmoji;
|
||||||
|
|
||||||
if (isLoading) return <h1>!!!</h1>;
|
if (isLoading) return <h1>!!!</h1>;
|
||||||
|
|
||||||
@@ -44,12 +44,12 @@ export const ControlButtons = ({
|
|||||||
</Button>
|
</Button>
|
||||||
{showCloseButton && (
|
{showCloseButton && (
|
||||||
<Button
|
<Button
|
||||||
className={classes.closeMedia}
|
className={classes.close}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
onClick={onCloseClick}
|
onClick={onCloseClick}
|
||||||
>
|
>
|
||||||
{t("APPS_TWITTER_CLOSE_MEDIA")}
|
{t("APPS_TWITTER_CLOSE_IMAGE")}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,11 +17,11 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const IconButtons = ({ onMediaClick, onEmojiClick }) => {
|
export const IconButtons = ({ onImageClick, onEmojiClick }) => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
return (
|
return (
|
||||||
<div className={classes.buttons}>
|
<div className={classes.buttons}>
|
||||||
<Button className={classes.button} onClick={onMediaClick}>
|
<Button className={classes.button} onClick={onImageClick}>
|
||||||
<InsertPhotoIcon color="action" />
|
<InsertPhotoIcon color="action" />
|
||||||
</Button>
|
</Button>
|
||||||
<Button className={classes.button} onClick={onEmojiClick}>
|
<Button className={classes.button} onClick={onEmojiClick}>
|
||||||
|
|||||||
+12
-5
@@ -7,7 +7,7 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
root: {
|
root: {
|
||||||
margin: "2px 15px",
|
margin: "2px 15px",
|
||||||
},
|
},
|
||||||
mediaImage: {
|
imageContainer: {
|
||||||
// catch the close button here so it doesn't go all the way up to the modal
|
// catch the close button here so it doesn't go all the way up to the modal
|
||||||
position: "relative",
|
position: "relative",
|
||||||
display: "inline-block",
|
display: "inline-block",
|
||||||
@@ -29,12 +29,18 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
maxWidth: "300px",
|
maxWidth: "300px",
|
||||||
padding: "0px 3px 3px 0px",
|
padding: "0px 3px 3px 0px",
|
||||||
},
|
},
|
||||||
|
imgSmall: {
|
||||||
|
maxHeight: "75px", // constrain images so we don't overwhelm the UI
|
||||||
|
maxWidth: "125px",
|
||||||
|
padding: "0px 1px 1px 0px",
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const MediaImage = ({ mediaLink, handleClick }) => {
|
export const Image = ({ link, handleClick, small }) => {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
return (
|
return (
|
||||||
<div className={classes.mediaImage}>
|
<div className={classes.imageContainer}>
|
||||||
|
{handleClick && (
|
||||||
<IconButton
|
<IconButton
|
||||||
className={classes.imgButton}
|
className={classes.imgButton}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
@@ -42,9 +48,10 @@ export const MediaImage = ({ mediaLink, handleClick }) => {
|
|||||||
>
|
>
|
||||||
<CloseIcon />
|
<CloseIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
<img className={classes.img} src={mediaLink} />
|
)}
|
||||||
|
<img className={small ? classes.imgSmall : classes.img} src={link} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MediaImage;
|
export default Image;
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { makeStyles } from "@material-ui/core/styles";
|
||||||
|
|
||||||
|
import Image from "./Image";
|
||||||
|
|
||||||
|
const useStyles = makeStyles((theme) => ({
|
||||||
|
root: {
|
||||||
|
margin: "2px 15px",
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
export const ImageDisplay = ({ visible, images, removeImage, small }) => {
|
||||||
|
const classes = useStyles();
|
||||||
|
if (!visible || !images || images.length === 0) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={classes.root}>
|
||||||
|
{images.map((link) => (
|
||||||
|
<Image
|
||||||
|
key={link}
|
||||||
|
link={link}
|
||||||
|
handleClick={removeImage ? () => removeImage(link) : null}
|
||||||
|
small={small}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
ImageDisplay.defaultProps = {
|
||||||
|
removeImage: null,
|
||||||
|
small: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ImageDisplay;
|
||||||
+3
-3
@@ -14,7 +14,7 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const MediaPrompt = ({ visible, value, handleChange }) => {
|
export const ImagePrompt = ({ visible, value, handleChange }) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
@@ -27,9 +27,9 @@ export const MediaPrompt = ({ visible, value, handleChange }) => {
|
|||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
multiline
|
multiline
|
||||||
size="small"
|
size="small"
|
||||||
placeholder={t("APPS_TWITTER_MEDIA_PLACEHOLDER")}
|
placeholder={t("APPS_TWITTER_IMAGE_PLACEHOLDER")}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MediaPrompt;
|
export default ImagePrompt;
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import { makeStyles } from "@material-ui/core/styles";
|
|
||||||
|
|
||||||
import types from "../types";
|
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
|
||||||
root: {
|
|
||||||
margin: "2px 15px",
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
import MediaImage from "./MediaImage";
|
|
||||||
|
|
||||||
export const Media = ({ id, mediaType, mediaLink, handleClose }) => {
|
|
||||||
switch (mediaType) {
|
|
||||||
case types.IMAGE:
|
|
||||||
case types.GIF:
|
|
||||||
return <MediaImage mediaLink={mediaLink} handleClick={handleClose} />;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export const MediaDisplay = ({ visible, media, removeMedia }) => {
|
|
||||||
const classes = useStyles();
|
|
||||||
if (!visible || media.length === 0) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={classes.root}>
|
|
||||||
{media.map((mediaItem) => (
|
|
||||||
<Media
|
|
||||||
key={mediaItem.id}
|
|
||||||
handleClose={() => removeMedia(mediaItem.id)}
|
|
||||||
{...mediaItem}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default MediaDisplay;
|
|
||||||
@@ -7,6 +7,7 @@ import ReplyIcon from "@material-ui/icons/Reply";
|
|||||||
import QuoteIcon from "@material-ui/icons/FormatQuote";
|
import QuoteIcon from "@material-ui/icons/FormatQuote";
|
||||||
|
|
||||||
import { ListItem } from "../../../ui/components/ListItem";
|
import { ListItem } from "../../../ui/components/ListItem";
|
||||||
|
import ImageDisplay from "./ImageDisplay";
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
root: {
|
root: {
|
||||||
@@ -26,11 +27,14 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const Tweet = ({ message, media }) => {
|
export const Tweet = (tweet) => {
|
||||||
|
const { message, images } = tweet;
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ListItem className={classes.root} divider>
|
<ListItem className={classes.root} divider>
|
||||||
<ListItemText className={classes.text} primary={message} />
|
<ListItemText className={classes.text} primary={message} />
|
||||||
|
<ImageDisplay visible images={images} small />
|
||||||
<div className={classes.buttonContainer}>
|
<div className={classes.buttonContainer}>
|
||||||
<Button>
|
<Button>
|
||||||
<FavoriteBorderIcon />
|
<FavoriteBorderIcon />
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { List } from "../../../ui/components/List";
|
|||||||
import { useTweets } from "../hooks/useTweets";
|
import { useTweets } from "../hooks/useTweets";
|
||||||
import Tweet from "./Tweet";
|
import Tweet from "./Tweet";
|
||||||
|
|
||||||
const TWEETS_REFRESH_RATE = 5000;
|
const TWEETS_REFRESH_RATE = 5000; // TODO move this to twitter config
|
||||||
|
|
||||||
export function TweetList() {
|
export function TweetList() {
|
||||||
const { tweets } = useTweets();
|
const { tweets } = useTweets();
|
||||||
@@ -17,6 +17,7 @@ export function TweetList() {
|
|||||||
}, TWEETS_REFRESH_RATE);
|
}, TWEETS_REFRESH_RATE);
|
||||||
return () => window.clearTimeout(timeout);
|
return () => window.clearTimeout(timeout);
|
||||||
}, []);
|
}, []);
|
||||||
|
console.log(tweets);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<List>
|
<List>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useNuiEvent } from "../../../os/nui-events/hooks/useNuiEvent";
|
import { useNuiEvent } from "../../../os/nui-events/hooks/useNuiEvent";
|
||||||
import { useSetRecoilState } from "recoil";
|
import { useSetRecoilState } from "recoil";
|
||||||
|
|
||||||
|
import { IMAGE_DELIMITER } from "../utils/images";
|
||||||
import types from "../types";
|
import types from "../types";
|
||||||
import { twitterState } from "./state";
|
import { twitterState } from "./state";
|
||||||
import { useTweets } from "./useTweets";
|
import { useTweets } from "./useTweets";
|
||||||
@@ -15,7 +16,20 @@ export const useTwitterService = () => {
|
|||||||
setCreateLoading(false); // on any result we should set loading to false
|
setCreateLoading(false); // on any result we should set loading to false
|
||||||
};
|
};
|
||||||
|
|
||||||
useNuiEvent(types.APP_TWITTER, "fetchTweets", setTweets);
|
const _setTweets = (tweets) => {
|
||||||
|
setTweets(
|
||||||
|
tweets.map((tweet) => {
|
||||||
|
return {
|
||||||
|
...tweet,
|
||||||
|
// we store images in the database as a varchar field with
|
||||||
|
// comma separated links to images
|
||||||
|
images: tweet.images ? tweet.images.split(IMAGE_DELIMITER) : [],
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
useNuiEvent(types.APP_TWITTER, "fetchTweets", _setTweets);
|
||||||
useNuiEvent(types.APP_TWITTER, "createTweetLoading", setCreateLoading);
|
useNuiEvent(types.APP_TWITTER, "createTweetLoading", setCreateLoading);
|
||||||
useNuiEvent(types.APP_TWITTER, "createTweetResult", _setCreateSuccess);
|
useNuiEvent(types.APP_TWITTER, "createTweetResult", _setCreateSuccess);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
// this is a hack. We are saving images in the database as
|
||||||
|
// delimiter separated URLS, but most common delimiters (comma, pipe
|
||||||
|
// hash, etc.) are often found in URLS (even though it's not technically
|
||||||
|
// within specification). To get around this we have our own delimiter
|
||||||
|
// here we'll use to join and split these strings
|
||||||
|
export const IMAGE_DELIMITER = "||!||";
|
||||||
|
|
||||||
|
export function withValidImage(link, onSuccess) {
|
||||||
|
// only add the media if it's a valid URL
|
||||||
|
const image = new Image();
|
||||||
|
image.onload = onSuccess;
|
||||||
|
image.onerror = () => {
|
||||||
|
console.warn(`Invalid image submitted: ${link}`);
|
||||||
|
};
|
||||||
|
image.src = link;
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
export function withValidMedia(link, onSuccess) {
|
|
||||||
// only add the media if it's a valid URL
|
|
||||||
const image = new Image();
|
|
||||||
image.onload = onSuccess;
|
|
||||||
image.onerror = () => {
|
|
||||||
console.warn(`Invalid image submitted: ${link}`);
|
|
||||||
};
|
|
||||||
image.src = link;
|
|
||||||
}
|
|
||||||
@@ -14,9 +14,9 @@
|
|||||||
"APPS_SETTINGS_OPTIONS_FRAME": "Frame",
|
"APPS_SETTINGS_OPTIONS_FRAME": "Frame",
|
||||||
"APPS_TWITTER": "Twitter",
|
"APPS_TWITTER": "Twitter",
|
||||||
"APPS_TWITTER_PLACEHOLDER": "What's happening?",
|
"APPS_TWITTER_PLACEHOLDER": "What's happening?",
|
||||||
"APPS_TWITTER_MEDIA_PLACEHOLDER": "A link to your image or gif",
|
"APPS_TWITTER_IMAGE_PLACEHOLDER": "A link to your image or gif",
|
||||||
"APPS_TWITTER_SUBMIT_MEDIA": "Add Media",
|
"APPS_TWITTER_SUBMIT_IMAGE": "Add Media",
|
||||||
"APPS_TWITTER_CLOSE_MEDIA": "Close",
|
"APPS_TWITTER_CLOSE_IMAGE": "Close",
|
||||||
"APPS_TWITTER_TWEET": "Tweet",
|
"APPS_TWITTER_TWEET": "Tweet",
|
||||||
"APPS_TWITTER_CLOSE": "Close",
|
"APPS_TWITTER_CLOSE": "Close",
|
||||||
"APPS_TWITTER_CREATE_FAILED": "Failed to send your tweet"
|
"APPS_TWITTER_CREATE_FAILED": "Failed to send your tweet"
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ end)
|
|||||||
|
|
||||||
|
|
||||||
RegisterNUICallback('phone:fetchTweets', function()
|
RegisterNUICallback('phone:fetchTweets', function()
|
||||||
print('RegisterNUICallback: phone:fetchTweets')
|
|
||||||
TriggerEvent('phone:fetchTweets')
|
TriggerEvent('phone:fetchTweets')
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,12 @@ ESX.RegisterServerCallback('phone:createTweet', function(source, cb, data)
|
|||||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||||
local _identifier = xPlayer.getIdentifier()
|
local _identifier = xPlayer.getIdentifier()
|
||||||
|
|
||||||
MySQL.Async.execute('INSERT INTO npwd_twitter_tweets (`identifier`, `realUser`, `message`) VALUES (@identifier, @realUser, @message)',
|
MySQL.Async.execute('INSERT INTO npwd_twitter_tweets (`identifier`, `realUser`, `message`, `images`) VALUES (@identifier, @realUser, @message, @images)',
|
||||||
{
|
{
|
||||||
['identifier'] = _identifier,
|
['identifier'] = _identifier,
|
||||||
['realUser'] = data.realUser,
|
['realUser'] = data.realUser,
|
||||||
['message'] = data.message
|
['message'] = data.message,
|
||||||
|
['images'] = data.images
|
||||||
}, function(result)
|
}, function(result)
|
||||||
cb(result)
|
cb(result)
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in new issue
Block a user