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:
Taso authored and GitHub committed 2021-03-22 13:37:07 -04:00
1 parent 53d5bb459d
commit 0f61088999
62 files changed
+4734 -3470

No files matched your search

@@ -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,
});
}