mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
refactor(events): Events are now tied to a common enum typings (#167)
* chore(scripts/twitter): Refactored twitter to use event enums * chore(scripts/marketplace): Refactored marketplace to use event enums * chore(scripts/messages): Refactored messages to use event enums * chore(scripts/contacts): Refactored contacts to use event enums * chore(scripts/calls): Refactored calls to use event enums * chore(scripts/notes): Refactored notes to use event enums * chore(scripts/photos): Refactored photos to use event enums * chore(scripts/bank): Refactored bank to use event enums * chore(scripts/phone): Refactored phone to use event enums * chore(events): Removed old events object * refactor(phone/nui-events): Attached NUI events to respective enum * tweak(event-enums): Added npwd prefix to all events * tweak(phone/serve): Added craco to override CRA without eject Also bumped react-scripts to 4.0.1, with seemingly no issues * fix(typings/twitter): Fixed method enums for twitter
This commit is contained in:
62 files changed
+4734
-3470
No files matched your search
@@ -0,0 +1,58 @@
|
||||
const {
|
||||
addAfterLoader,
|
||||
removeLoaders,
|
||||
loaderByName,
|
||||
getLoaders,
|
||||
throwUnexpectedConfigError,
|
||||
} = require('@craco/craco');
|
||||
|
||||
const throwError = (message) =>
|
||||
throwUnexpectedConfigError({
|
||||
packageName: 'craco',
|
||||
githubRepo: 'gsoft-inc/craco',
|
||||
message,
|
||||
githubIssueQuery: 'webpack',
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
webpack: {
|
||||
configure: (webpackConfig, { paths }) => {
|
||||
const { hasFoundAny, matches } = getLoaders(webpackConfig, loaderByName('babel-loader'));
|
||||
if (!hasFoundAny) throwError('failed to find babel-loader');
|
||||
|
||||
const { hasRemovedAny, removedCount } = removeLoaders(
|
||||
webpackConfig,
|
||||
loaderByName('babel-loader'),
|
||||
);
|
||||
if (!hasRemovedAny) throwError('no babel-loader to remove');
|
||||
if (removedCount !== 2) throwError('had expected to remove 2 babel loader instances');
|
||||
webpackConfig.resolve.plugins = webpackConfig.resolve.plugins.filter(
|
||||
({ constructor: c }) => !c || c.name !== 'ModuleScopePlugin',
|
||||
);
|
||||
|
||||
const tsLoader = {
|
||||
test: /\.tsx?$/,
|
||||
loader: require.resolve('ts-loader'),
|
||||
options: { transpileOnly: true },
|
||||
};
|
||||
|
||||
const { isAdded: tsLoaderIsAdded } = addAfterLoader(
|
||||
webpackConfig,
|
||||
loaderByName('url-loader'),
|
||||
tsLoader,
|
||||
);
|
||||
|
||||
if (!tsLoaderIsAdded) throwError('failed to add ts-loader');
|
||||
|
||||
const { isAdded: babelLoaderIsAdded } = addAfterLoader(
|
||||
webpackConfig,
|
||||
loaderByName('ts-loader'),
|
||||
matches[1].loader, // babel-loader
|
||||
);
|
||||
|
||||
if (!babelLoaderIsAdded) throwError('failed to add back babel-loader for non-application JS');
|
||||
|
||||
return webpackConfig;
|
||||
},
|
||||
},
|
||||
};
|
||||
+5
-3
@@ -33,7 +33,7 @@
|
||||
"react-i18next": "^11.7.1",
|
||||
"react-popper": "^2.2.3",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"react-scripts": "3.4.3",
|
||||
"react-scripts": "4.0.1",
|
||||
"recoil": "^0.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -43,6 +43,7 @@
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
||||
"@babel/preset-env": "^7.4.5",
|
||||
"@babel/preset-react": "^7.0.0",
|
||||
"@craco/craco": "^6.1.1",
|
||||
"@testing-library/jest-dom": "^4.2.4",
|
||||
"@testing-library/react": "^9.5.0",
|
||||
"@testing-library/user-event": "^7.2.1",
|
||||
@@ -63,6 +64,7 @@
|
||||
"cra-build-watch": "^3.2.0",
|
||||
"cross-env": "^7.0.2",
|
||||
"css-loader": "^2.1.1",
|
||||
"customize-cra": "^1.0.0",
|
||||
"file-loader": "^3.0.1",
|
||||
"html-loader": "^0.5.5",
|
||||
"html-webpack-plugin": "^4.3.0",
|
||||
@@ -79,11 +81,11 @@
|
||||
"scripts": {
|
||||
"i18n:missing": "node --experimental-json-modules i18n.missingKeys.js",
|
||||
"copy:config": "cp-cli ../config.json ./src/config.autogen.json",
|
||||
"start": "yarn copy:config && react-scripts start",
|
||||
"start": "craco start",
|
||||
"watch": "cra-build-watch --disable-chunks --build-path ../resources/html --output-filename dev.js",
|
||||
"build": "yarn copy:config && cross-env NODE_ENV=production webpack --config webpack/prod.config.js --color -p --progress --hide-modules --display-optimization-bailout",
|
||||
"build:dev": "cross-env NODE_ENV=development webpack --config webpack/dev.config.js --color -p --progress --hide-modules --display-optimization-bailout --analyze",
|
||||
"test": "react-scripts test --watchAll=false --testMatch **/src/**/*.test.{ts,js,tsx}",
|
||||
"test": "craco test --watchAll=false --testMatch **/src/**/*.test.{ts,js,tsx}",
|
||||
"test:watch": "react-scripts test --watchAll --testMatch **/src/**/*.test.{ts,js,tsx}",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
|
||||
@@ -5,6 +5,7 @@ import { Button, List, ListItem, TextField, makeStyles } from '@material-ui/core
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
|
||||
import { useBankModal } from '../../hooks/useBankModal';
|
||||
import { BankEvents } from '../../../../../../typings/bank';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
input: {
|
||||
@@ -43,7 +44,7 @@ export const TransferModal = () => {
|
||||
|
||||
const addTransfer = () => {
|
||||
const transferAmount = parseInt(amount);
|
||||
Nui.send('phone:addTransfer', {
|
||||
Nui.send(BankEvents.ADD_TRANSFER, {
|
||||
targetID,
|
||||
transferAmount,
|
||||
message,
|
||||
|
||||
@@ -8,6 +8,7 @@ import { useHistory } from 'react-router-dom';
|
||||
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
||||
import { addQueryToLocation } from '../../../../common/utils/addQueryToLocation';
|
||||
import { getLocationFromUrl } from '../../../../common/utils/getLocationFromUrl';
|
||||
import { PhotoEvents } from '../../../../../../typings/photo';
|
||||
|
||||
export const GalleryGrid = () => {
|
||||
const classes = useStyles();
|
||||
@@ -19,7 +20,7 @@ export const GalleryGrid = () => {
|
||||
const photos = usePhotos();
|
||||
|
||||
const handleCamera = () => {
|
||||
Nui.send('phone:TakePhoto', {});
|
||||
Nui.send(PhotoEvents.TAKE_PHOTO, {});
|
||||
};
|
||||
|
||||
const handlePhotoOpen = (photo) => {
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useHistory } from 'react-router-dom';
|
||||
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
||||
import { ICameraPhoto } from '../../hooks/usePhotos';
|
||||
import { ShareModal } from './ShareModal';
|
||||
import { PhotoEvents } from '../../../../../../typings/photo';
|
||||
|
||||
export const GalleryModal = () => {
|
||||
const classes = useStyles();
|
||||
@@ -28,7 +29,7 @@ export const GalleryModal = () => {
|
||||
};
|
||||
|
||||
const handleDeletePhoto = () => {
|
||||
Nui.send('photo:deletePhoto', {
|
||||
Nui.send(PhotoEvents.DELETE_PHOTO, {
|
||||
image: meta.image,
|
||||
});
|
||||
history.push(referal);
|
||||
|
||||
@@ -10,6 +10,7 @@ import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { SearchContacts } from './SearchContacts';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
|
||||
import { CallEvents } from '../../../../../../typings/call';
|
||||
|
||||
export const ContactList = () => {
|
||||
const { filteredContacts } = useFilteredContacts();
|
||||
@@ -27,7 +28,7 @@ export const ContactList = () => {
|
||||
level: 2,
|
||||
data: true,
|
||||
});
|
||||
Nui.send('phone:beginCall', {
|
||||
Nui.send(CallEvents.INITIALIZE_CALL, {
|
||||
number,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -8,6 +8,7 @@ import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||
import LogDebugEvent from '../../../../os/debug/LogDebugEvents';
|
||||
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
||||
import { ContactEvents } from '../../../../../../typings/contact';
|
||||
|
||||
interface ContactInfoRouteParams {
|
||||
mode: string;
|
||||
@@ -79,7 +80,7 @@ const ContactsInfoPage = () => {
|
||||
data: contact,
|
||||
level: 2,
|
||||
});
|
||||
Nui.send('phone:addContacts', {
|
||||
Nui.send(ContactEvents.ADD_CONTACT, {
|
||||
display: name,
|
||||
number,
|
||||
avatar,
|
||||
@@ -93,7 +94,7 @@ const ContactsInfoPage = () => {
|
||||
data: contact,
|
||||
level: 2,
|
||||
});
|
||||
Nui.send('phone:updateContact', {
|
||||
Nui.send(ContactEvents.UPDATE_CONTACT, {
|
||||
id: contact.id,
|
||||
display: name,
|
||||
number,
|
||||
@@ -108,7 +109,7 @@ const ContactsInfoPage = () => {
|
||||
data: contact,
|
||||
level: 2,
|
||||
});
|
||||
Nui.send('phone:deleteContact', {
|
||||
Nui.send(ContactEvents.DELETE_CONTACT, {
|
||||
id: contact.id,
|
||||
});
|
||||
history.goBack();
|
||||
|
||||
@@ -6,6 +6,7 @@ import PersonAddIcon from '@material-ui/icons/PersonAdd';
|
||||
import { DialInputCtx, IDialInputCtx } from '../context/InputContext';
|
||||
import Nui from '../../../os/nui-events/utils/Nui';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { CallEvents } from '../../../../../typings/call';
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
root: {
|
||||
@@ -33,7 +34,7 @@ export const DialerInput = () => {
|
||||
const { inputVal, set } = useContext<IDialInputCtx>(DialInputCtx);
|
||||
|
||||
const handleCall = (number: string) => {
|
||||
Nui.send('phone:beginCall', {
|
||||
Nui.send(CallEvents.INITIALIZE_CALL, {
|
||||
number,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ import { ListItem } from '../../../../ui/components/ListItem';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
|
||||
import { useContacts } from '../../../contacts/hooks/useContacts';
|
||||
import { ICall } from '../../../../../../typings/call';
|
||||
import { CallEvents, ICall } from '../../../../../../typings/call';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Box, IconButton, ListItemIcon, ListItemText } from '@material-ui/core';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
@@ -35,7 +35,7 @@ export const DialerHistory = ({ calls }) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleCall = (phoneNumber) => {
|
||||
Nui.send('phone:beginCall', {
|
||||
Nui.send(CallEvents.INITIALIZE_CALL, {
|
||||
number: phoneNumber,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -11,13 +11,14 @@ import InjectDebugData from '../../../os/debug/InjectDebugData';
|
||||
import NewMessageGroupButton from './form/NewMessageGroupButton';
|
||||
import Nui from '../../../os/nui-events/utils/Nui';
|
||||
import { MessagesThemeProvider } from '../providers/MessagesThemeProvider';
|
||||
import { MessageEvents } from '../../../../../typings/messages';
|
||||
|
||||
export const MessagesApp = () => {
|
||||
const messages = useApp('MESSAGES');
|
||||
const history = useHistory();
|
||||
|
||||
useEffect(() => {
|
||||
Nui.send('phone:fetchMessageGroups');
|
||||
Nui.send(MessageEvents.FETCH_MESSAGE_GROUPS);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Paper, Box, makeStyles, TextField, Button } from '@material-ui/core';
|
||||
import SendIcon from '@material-ui/icons/Send';
|
||||
import ImageIcon from '@material-ui/icons/Image';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { MessageEvents } from '../../../../../../typings/messages';
|
||||
|
||||
interface IProps {
|
||||
onAddImageClick(): void;
|
||||
@@ -25,7 +26,7 @@ const MessageInput = ({ messageGroupId, onAddImageClick }: IProps) => {
|
||||
if (message.trim()) {
|
||||
// don't allow the user to submit white space
|
||||
|
||||
Nui.send('phone:sendMessage', {
|
||||
Nui.send(MessageEvents.SEND_MESSAGE, {
|
||||
groupId: messageGroupId,
|
||||
message,
|
||||
});
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useHistory } from 'react-router-dom';
|
||||
import { Autocomplete } from '@material-ui/lab';
|
||||
import { useContacts } from '../../../contacts/hooks/useContacts';
|
||||
import { Contact } from '../../../../../../typings/contact';
|
||||
import { MessageEvents } from '../../../../../../typings/messages';
|
||||
|
||||
const NewMessageGroupForm = ({ phoneNumber }: { phoneNumber?: string }) => {
|
||||
const history = useHistory();
|
||||
@@ -32,7 +33,7 @@ const NewMessageGroupForm = ({ phoneNumber }: { phoneNumber?: string }) => {
|
||||
const labelValue = isGroupChat ? label.trim() : null;
|
||||
|
||||
if (phoneNumbers.length) {
|
||||
Nui.send('phone:createMessageGroup', {
|
||||
Nui.send(MessageEvents.CREATE_MESSAGE_GROUP, {
|
||||
phoneNumbers,
|
||||
label: labelValue,
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Box, List } from '@material-ui/core';
|
||||
import { MessageGroup } from '../../../../../../typings/messages';
|
||||
import { MessageEvents, MessageGroup } from '../../../../../../typings/messages';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import useMessages from '../../hooks/useMessages';
|
||||
import MessageGroupItem from './MessageGroupItem';
|
||||
|
||||
@@ -10,6 +10,7 @@ import { useHistory, useLocation } from 'react-router-dom';
|
||||
import { ContextMenu } from '../../../../ui/components/ContextMenu';
|
||||
import { deleteQueryFromLocation } from '../../../../common/utils/deleteQueryFromLocation';
|
||||
import { PictureResponsive } from '../../../../ui/components/PictureResponsive';
|
||||
import { MessageEvents } from '../../../../../../typings/messages';
|
||||
|
||||
interface IProps {
|
||||
isOpen: boolean;
|
||||
@@ -34,7 +35,7 @@ export const MessageImageModal = ({ isOpen, messageGroupId, onClose, image }: IP
|
||||
|
||||
const sendImageMessage = useCallback(
|
||||
(m) => {
|
||||
Nui.send('phone:sendMessage', {
|
||||
Nui.send(MessageEvents.SEND_MESSAGE, {
|
||||
groupId: messageGroupId,
|
||||
message: m,
|
||||
});
|
||||
|
||||
@@ -23,6 +23,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import Modal from '../../../../ui/components/Modal';
|
||||
import { useContacts } from '../../../contacts/hooks/useContacts';
|
||||
import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
|
||||
import { MessageEvents } from '../../../../../../typings/messages';
|
||||
|
||||
const LARGE_HEADER_CHARS = 30;
|
||||
const MAX_HEADER_CHARS = 80;
|
||||
@@ -92,7 +93,7 @@ export const MessageModal = () => {
|
||||
// sends all unread messages
|
||||
useEffect(() => {
|
||||
if (activeMessageGroup?.groupId && activeMessageGroup.unreadCount > 0) {
|
||||
Nui.send('phone:setReadMessages', {
|
||||
Nui.send(MessageEvents.SET_MESSAGE_READ, {
|
||||
groupId: activeMessageGroup.groupId,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import Nui from '../../../os/nui-events/utils/Nui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { StatusButton } from '../../../ui/components/StatusButton';
|
||||
import { NotesEvents } from '../../../../../typings/notes';
|
||||
|
||||
export const NoteModal = () => {
|
||||
const classes = useStyles();
|
||||
@@ -31,14 +32,14 @@ export const NoteModal = () => {
|
||||
};
|
||||
|
||||
const handleNoteSave = () => {
|
||||
Nui.send('phone:addNote', detail);
|
||||
Nui.send(NotesEvents.ADD_NOTE, detail);
|
||||
setDetail(null);
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleDeleteNote = () => {
|
||||
const id = detail.id;
|
||||
Nui.send('phone:deleteNote', {
|
||||
Nui.send(NotesEvents.DELETE_NOTE, {
|
||||
id,
|
||||
});
|
||||
setDetail(null);
|
||||
@@ -46,7 +47,7 @@ export const NoteModal = () => {
|
||||
};
|
||||
|
||||
const handleUpdateNote = () => {
|
||||
Nui.send('phone:updateNote', detail);
|
||||
Nui.send(NotesEvents.UPDATE_NOTE, detail);
|
||||
setDetail(null);
|
||||
onClose();
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Box, Tooltip, Button } from '@material-ui/core';
|
||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||
import React from 'react';
|
||||
import { MarketplaceListing } from '../../../../../../typings/marketplace';
|
||||
import { MarketplaceEvents, MarketplaceListing } from '../../../../../../typings/marketplace';
|
||||
import { useSimcard } from '../../../../os/simcard/hooks/useSimcard';
|
||||
import DeleteIcon from '@material-ui/icons/Delete';
|
||||
import ReportIcon from '@material-ui/icons/Report';
|
||||
@@ -10,6 +10,7 @@ import PhoneIcon from '@material-ui/icons/Phone';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useHistory } from 'react-router';
|
||||
import { CallEvents } from '../../../../../../typings/call';
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
icon: {
|
||||
@@ -24,17 +25,17 @@ export const ListingActions = ({ listing }: { listing: MarketplaceListing }) =>
|
||||
const history = useHistory();
|
||||
|
||||
const handleDeleteListing = () => {
|
||||
Nui.send('phone:marketplaceDeleteListing', {
|
||||
Nui.send(MarketplaceEvents.DELETE_LISTING, {
|
||||
id: listing.id,
|
||||
});
|
||||
};
|
||||
|
||||
const handleReportListing = () => {
|
||||
Nui.send('phone:reportListing', listing);
|
||||
Nui.send(MarketplaceEvents.REPORT_LISTING, listing);
|
||||
};
|
||||
|
||||
const handleCall = () => {
|
||||
Nui.send('phone:beginCall', {
|
||||
Nui.send(CallEvents.INITIALIZE_CALL, {
|
||||
number: listing.number,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React, { useState } from 'react';
|
||||
import { makeStyles, Button, TextField } from '@material-ui/core';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { MarketplaceEvents } from '../../../../../../typings/marketplace';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
@@ -34,7 +35,7 @@ export const ListingForm = () => {
|
||||
const [description, setDescription] = useState('');
|
||||
|
||||
const addListing = () => {
|
||||
Nui.send('phone:addListing', {
|
||||
Nui.send(MarketplaceEvents.ADD_LISTING, {
|
||||
title,
|
||||
url,
|
||||
description,
|
||||
|
||||
@@ -15,7 +15,7 @@ import ControlButtons from './buttons/ControlButtons';
|
||||
import IconButtons from './buttons/IconButtons';
|
||||
import { usePhone } from '../../../os/phone/hooks/usePhone';
|
||||
import { getNewLineCount } from '../utils/message';
|
||||
import { NewTweet } from '../../../../../typings/twitter';
|
||||
import { NewTweet, TwitterEvents } from '../../../../../typings/twitter';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
@@ -110,7 +110,7 @@ export const AddTweetModal = () => {
|
||||
images:
|
||||
images && images.length > 0 ? images.map((image) => image.link).join(IMAGE_DELIMITER) : '',
|
||||
};
|
||||
Nui.send('phone:createTweet', data);
|
||||
Nui.send(TwitterEvents.CREATE_TWEET, data);
|
||||
_handleClose();
|
||||
};
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import { useProfile } from '../hooks/useProfile';
|
||||
import ProfilePrompt from './profile/ProfilePrompt';
|
||||
import InjectDebugData from '../../../os/debug/InjectDebugData';
|
||||
import { TwitterThemeProvider } from '../providers/TwitterThemeProvider';
|
||||
import { TwitterEvents } from '../../../../../typings/twitter';
|
||||
|
||||
const useStyles = makeStyles(() => ({
|
||||
backgroundModal: {
|
||||
|
||||
@@ -7,6 +7,7 @@ import TweetList from './tweet/TweetList';
|
||||
import Nui from '../../../os/nui-events/utils/Nui';
|
||||
import SearchButton from './buttons/SearchButton';
|
||||
import { useFilteredTweets } from '../hooks/useFilteredTweets';
|
||||
import { TwitterEvents } from '../../../../../typings/twitter';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
root: {
|
||||
@@ -32,7 +33,7 @@ function TwitterSearch() {
|
||||
const cleanedSearchValue = searchValue.trim();
|
||||
if (!cleanedSearchValue) return;
|
||||
|
||||
Nui.send('phone:fetchTweetsFiltered', cleanedSearchValue);
|
||||
Nui.send(TwitterEvents.FETCH_TWEETS_FILTERED, cleanedSearchValue);
|
||||
};
|
||||
|
||||
const filteredTweets = tweets || [];
|
||||
|
||||
@@ -4,6 +4,7 @@ import FavoriteBorderIcon from '@material-ui/icons/FavoriteBorder';
|
||||
import FavoriteIcon from '@material-ui/icons/Favorite';
|
||||
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { TwitterEvents } from '../../../../../../typings/twitter';
|
||||
|
||||
const LOADING_TIME = 1250;
|
||||
|
||||
@@ -12,7 +13,7 @@ function LikeButton({ tweetId, isLiked }) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const handleClick = () => {
|
||||
Nui.send('phone:toggleLike', tweetId);
|
||||
Nui.send(TwitterEvents.TOGGLE_LIKE, tweetId);
|
||||
setLoading(true);
|
||||
window.setTimeout(() => {
|
||||
setLiked(!liked);
|
||||
|
||||
@@ -4,6 +4,7 @@ import { Button, CircularProgress, MenuItem } from '@material-ui/core';
|
||||
import DoneIcon from '@material-ui/icons/Done';
|
||||
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { TwitterEvents } from '../../../../../../typings/twitter';
|
||||
|
||||
const LOADING_TIME = 1250;
|
||||
|
||||
@@ -12,7 +13,7 @@ function ReportButton({ handleClose, tweetId, isReported }) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const handleClick = () => {
|
||||
Nui.send('phone:reportTweet', tweetId);
|
||||
Nui.send(TwitterEvents.REPORT, tweetId);
|
||||
setLoading(true);
|
||||
window.setTimeout(() => {
|
||||
setLoading(false);
|
||||
|
||||
@@ -3,6 +3,7 @@ import { CircularProgress, makeStyles, Button } from '@material-ui/core';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faRetweet } from '@fortawesome/free-solid-svg-icons';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { TwitterEvents } from '../../../../../../typings/twitter';
|
||||
|
||||
interface IProps {
|
||||
tweetId: number;
|
||||
@@ -33,7 +34,7 @@ export const RetweetButton = ({ tweetId, isRetweet, retweetId }: IProps) => {
|
||||
// if someone is retweeting something that is itself a retweet
|
||||
// then we want to retweet the original post (if we haven't already)
|
||||
const idToRetweet = isRetweet ? retweetId : tweetId;
|
||||
Nui.send('phone:retweet', idToRetweet);
|
||||
Nui.send(TwitterEvents.RETWEET, idToRetweet);
|
||||
setLoading(true);
|
||||
window.setTimeout(() => {
|
||||
setRetweeted(true);
|
||||
|
||||
@@ -8,6 +8,7 @@ import Avatar from '../Avatar';
|
||||
import ProfileField from './ProfileField';
|
||||
import ProfileUpdateButton from '../buttons/ProfileUpdateButton';
|
||||
import { usePhone } from '../../../../os/phone/hooks/usePhone';
|
||||
import { TwitterEvents } from '../../../../../../typings/twitter';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
@@ -46,7 +47,7 @@ export function Profile() {
|
||||
location,
|
||||
job,
|
||||
};
|
||||
Nui.send('phone:updateTwitterProfile', data);
|
||||
Nui.send(TwitterEvents.UPDATE_PROFILE, data);
|
||||
};
|
||||
|
||||
// fetching the config is an asynchronous call so defend against it
|
||||
|
||||
@@ -10,6 +10,7 @@ import ProfileUpdateButton from '../buttons/ProfileUpdateButton';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { twitterState } from '../../hooks/state';
|
||||
import { usePhone } from '../../../../os/phone/hooks/usePhone';
|
||||
import { TwitterEvents } from '../../../../../../typings/twitter';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
@@ -33,8 +34,8 @@ export function ProfilePrompt() {
|
||||
|
||||
const showDefaultProfileNames = !config.twitter.allowEdtiableProfileName && !profile;
|
||||
const eventName = showDefaultProfileNames
|
||||
? 'phone:createTwitterProfile'
|
||||
: 'phone:updateTwitterProfile';
|
||||
? TwitterEvents.CREATE_PROFILE
|
||||
: TwitterEvents.UPDATE_PROFILE;
|
||||
|
||||
const handleUpdate = () => {
|
||||
Nui.send(eventName, {
|
||||
|
||||
@@ -5,6 +5,7 @@ import MoreIcon from '@material-ui/icons/MoreVert';
|
||||
import { usePhone } from '../../../../os/phone/hooks/usePhone';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import ReportButton from '../buttons/ReportButton';
|
||||
import { TwitterEvents } from '../../../../../../typings/twitter';
|
||||
|
||||
export const ShowMore = ({ id, isReported, isMine }) => {
|
||||
const [anchorEl, setAnchorEl] = useState<Element | null>(null);
|
||||
@@ -23,7 +24,7 @@ export const ShowMore = ({ id, isReported, isMine }) => {
|
||||
};
|
||||
|
||||
const handleDeleteTweet = () => {
|
||||
Nui.send('phone:deleteTweet', id);
|
||||
Nui.send(TwitterEvents.DELETE_TWEET, id);
|
||||
handleClose();
|
||||
};
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@ import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { useTweets } from '../../hooks/useTweets';
|
||||
import { useTwitterNotifications } from '../../hooks/useTwitterNotifications';
|
||||
import TweetList from './TweetList';
|
||||
import { TwitterEvents } from '../../../../../../typings/twitter';
|
||||
|
||||
export function TweetListContainer() {
|
||||
const { tweets } = useTweets();
|
||||
const { setUnreadCount } = useTwitterNotifications();
|
||||
|
||||
useEffect(() => {
|
||||
Nui.send('phone:fetchTweets', {});
|
||||
Nui.send(TwitterEvents.FETCH_TWEETS, {});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import Nui from '../../nui-events/utils/Nui';
|
||||
|
||||
export const AppWithStartup = ({ children, id }) => {
|
||||
useEffect(() => {
|
||||
Nui.send(`phone:app:${id}`);
|
||||
Nui.send(`npwd:app:${id}`);
|
||||
}, [id]);
|
||||
return children;
|
||||
};
|
||||
@@ -2,6 +2,7 @@ import { useRecoilState } from 'recoil';
|
||||
import { CallProps } from '../../../../../typings/call';
|
||||
import Nui from '../../nui-events/utils/Nui';
|
||||
import { callerState } from './state';
|
||||
import { CallEvents } from '../../../../../typings/call';
|
||||
|
||||
interface CallHook {
|
||||
call: CallProps;
|
||||
@@ -15,19 +16,19 @@ export const useCall = (): CallHook => {
|
||||
const [call, setCall] = useRecoilState(callerState.currentCall);
|
||||
|
||||
const acceptCall = () => {
|
||||
Nui.send('phone:acceptCall', {
|
||||
Nui.send(CallEvents.ACCEPT_CALL, {
|
||||
transmitterNumber: call.transmitter,
|
||||
});
|
||||
};
|
||||
|
||||
const rejectCall = () => {
|
||||
Nui.send('phone:rejectCall', {
|
||||
Nui.send(CallEvents.REJECTED, {
|
||||
phoneNumber: call.transmitter,
|
||||
});
|
||||
};
|
||||
|
||||
const endCall = () => {
|
||||
Nui.send('phone:endCall', {
|
||||
Nui.send(CallEvents.END_CALL, {
|
||||
transmitterNumber: call.transmitter,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -4,6 +4,7 @@ import ServerConfig from '../../../config.autogen.json';
|
||||
import { useNotifications } from '../../notifications/hooks/useNotifications';
|
||||
import Nui from '../../nui-events/utils/Nui';
|
||||
import { phoneState } from './state';
|
||||
import { PhoneEvents } from '../../../../../typings/phone';
|
||||
|
||||
interface IUsePhone {
|
||||
config?: IServerConfig;
|
||||
@@ -21,10 +22,10 @@ export const usePhone = (): IUsePhone => {
|
||||
|
||||
const closePhone = () => {
|
||||
removeAlerts();
|
||||
Nui.send('phone:close');
|
||||
Nui.send(PhoneEvents.CLOSE_PHONE);
|
||||
};
|
||||
const openPhone = () => {
|
||||
Nui.send('phone:open');
|
||||
Nui.send(PhoneEvents.OPEN_PHONE);
|
||||
};
|
||||
|
||||
return { config: ServerConfig as any, closePhone, openPhone, isPhoneOpen, isPhoneReady };
|
||||
|
||||
+10
-3
@@ -1,7 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
@@ -16,7 +20,10 @@
|
||||
"noEmit": true,
|
||||
"jsx": "react",
|
||||
"strictNullChecks": false,
|
||||
"sourceMap": true
|
||||
"sourceMap": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src"]
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
||||
+4021
-2833
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user