mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +00:00
Merge branch 'master' into feat/alerts-for-apps
This commit is contained in:
79 files changed
+1716
-970
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { SvgIcon } from '@material-ui/core';
|
||||
import { SvgIcon, SvgIconProps } from '@material-ui/core';
|
||||
|
||||
export const CalculatorIcon = ({ ...props }) => {
|
||||
export const CalculatorIcon = ({ ...props}: SvgIconProps) => {
|
||||
return (
|
||||
<SvgIcon {...props}>
|
||||
<svg
|
||||
|
||||
@@ -16,7 +16,7 @@ InjectDebugData([
|
||||
image: 'https://i.imgur.com/OO8wx6Z.jpg',
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
id: 2,
|
||||
image: 'https://i.imgur.com/pqGBiST.jpg',
|
||||
},
|
||||
],
|
||||
|
||||
@@ -27,12 +27,12 @@ export const GalleryModal = () => {
|
||||
history.push(referal);
|
||||
};
|
||||
|
||||
const handleDeletePhoto = useCallback(() => {
|
||||
const handleDeletePhoto = () => {
|
||||
Nui.send('photo:deletePhoto', {
|
||||
id: meta.id,
|
||||
image: meta.image,
|
||||
});
|
||||
history.push(referal);
|
||||
}, [history, meta.id, referal]);
|
||||
};
|
||||
|
||||
const handleSharePhoto = useCallback(() => {
|
||||
setShareOpen(meta);
|
||||
@@ -42,7 +42,11 @@ export const GalleryModal = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<ShareModal referal={referal} meta={shareOpen} onClose={() => setShareOpen(null)} />
|
||||
<ShareModal
|
||||
referal={referal}
|
||||
meta={shareOpen}
|
||||
onClose={() => setShareOpen(null)}
|
||||
/>
|
||||
<Paper className={classes.modal}>
|
||||
<div className={shareOpen ? classes.backgroundModal : null} />
|
||||
<Button onClick={_handleClose}>
|
||||
|
||||
@@ -45,7 +45,7 @@ InjectDebugData([
|
||||
{
|
||||
id: 3,
|
||||
display: 'Chip',
|
||||
number: '417-8792',
|
||||
number: '777-7777',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import {
|
||||
Avatar as MuiAvatar,
|
||||
Box,
|
||||
@@ -13,12 +13,18 @@ import { useContacts } from '../../hooks/useContacts';
|
||||
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';
|
||||
|
||||
interface ContactInfoRouteParams {
|
||||
mode: string;
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface ContactInfoRouteQuery {
|
||||
addNumber?: string;
|
||||
referal?: string;
|
||||
}
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
root: {
|
||||
height: '100%',
|
||||
@@ -54,6 +60,7 @@ const ContactsInfoPage = () => {
|
||||
const { getContact } = useContacts();
|
||||
|
||||
const { id } = useParams<ContactInfoRouteParams>();
|
||||
const { addNumber, referal } = useQueryParams<ContactInfoRouteQuery>({ referal: '/contacts' });
|
||||
|
||||
const contact = getContact(parseInt(id));
|
||||
|
||||
@@ -64,6 +71,12 @@ const ContactsInfoPage = () => {
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
useEffect(() => {
|
||||
if (addNumber) {
|
||||
setNumber(addNumber);
|
||||
}
|
||||
}, [addNumber]);
|
||||
|
||||
const handleContactAdd = () => {
|
||||
LogDebugEvent({
|
||||
action: 'Handling Contact Add',
|
||||
@@ -75,7 +88,7 @@ const ContactsInfoPage = () => {
|
||||
number,
|
||||
avatar,
|
||||
});
|
||||
history.goBack();
|
||||
history.replace(referal);
|
||||
};
|
||||
|
||||
const handleContactSave = () => {
|
||||
@@ -113,6 +126,7 @@ const ContactsInfoPage = () => {
|
||||
<div className={classes.listContainer}>
|
||||
<MuiAvatar className={classes.avatar} src={avatar} />
|
||||
<TextField
|
||||
autoFocus
|
||||
className={classes.input}
|
||||
value={name}
|
||||
onChange={(e) => setName(e.target.value)}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
root: {
|
||||
backgroundColor: '#e9e9e9',
|
||||
backgroundColor: theme.palette.background.default,
|
||||
},
|
||||
}));
|
||||
|
||||
|
||||
@@ -10,6 +10,32 @@ import DialerNavBar from './DialerNavBar';
|
||||
import { useDialHistory } from '../hooks/useDialHistory';
|
||||
import InjectDebugData from '../../../os/debug/InjectDebugData';
|
||||
import { ContactList } from '../../contacts/components/List/ContactList';
|
||||
import { DialerThemeProvider } from '../providers/DialerThemeProvider';
|
||||
|
||||
export const DialerApp = () => {
|
||||
const history = useDialHistory();
|
||||
|
||||
const dialer = useApp('DIALER');
|
||||
return (
|
||||
<DialerThemeProvider>
|
||||
<AppWrapper>
|
||||
<AppTitle app={dialer} />
|
||||
<AppContent>
|
||||
<Switch>
|
||||
<Route path='/phone/dial'>
|
||||
<DialPage />
|
||||
</Route>
|
||||
<Route exact path='/phone'>
|
||||
<DialerHistory calls={history} />
|
||||
</Route>
|
||||
<Route path='/phone/contacts' component={ContactList}></Route>
|
||||
</Switch>
|
||||
</AppContent>
|
||||
<DialerNavBar />
|
||||
</AppWrapper>
|
||||
</DialerThemeProvider>
|
||||
);
|
||||
};
|
||||
|
||||
InjectDebugData([
|
||||
{
|
||||
@@ -29,26 +55,3 @@ InjectDebugData([
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
export const DialerApp = () => {
|
||||
const history = useDialHistory();
|
||||
|
||||
const dialer = useApp('DIALER');
|
||||
return (
|
||||
<AppWrapper>
|
||||
<AppTitle app={dialer} />
|
||||
<AppContent>
|
||||
<Switch>
|
||||
<Route path='/phone/dial'>
|
||||
<DialPage />
|
||||
</Route>
|
||||
<Route exact path='/phone'>
|
||||
<DialerHistory calls={history} />
|
||||
</Route>
|
||||
<Route path='/phone/contacts' component={ContactList}></Route>
|
||||
</Switch>
|
||||
</AppContent>
|
||||
<DialerNavBar />
|
||||
</AppWrapper>
|
||||
);
|
||||
};
|
||||
@@ -2,8 +2,10 @@ import React, { useContext } from 'react';
|
||||
import { Box, IconButton, InputBase, Paper } from '@material-ui/core';
|
||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||
import PhoneIcon from '@material-ui/icons/Phone';
|
||||
import PersonAddIcon from '@material-ui/icons/PersonAdd';
|
||||
import { DialInputCtx } from '../context/InputContext';
|
||||
import Nui from '../../../os/nui-events/utils/Nui';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
root: {
|
||||
@@ -26,8 +28,9 @@ const useStyles = makeStyles((theme: Theme) => ({
|
||||
|
||||
export const DialerInput = () => {
|
||||
const classes = useStyles();
|
||||
const history = useHistory();
|
||||
|
||||
const { inputVal } = useContext(DialInputCtx)
|
||||
const { inputVal } = useContext(DialInputCtx);
|
||||
|
||||
const handleCall = (number: string) => {
|
||||
Nui.send('phone:beginCall', {
|
||||
@@ -35,6 +38,10 @@ export const DialerInput = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleNewContact = (number: string) => {
|
||||
history.push(`/contacts/-1/?addNumber=${number}&referal=/phone/contacts`)
|
||||
}
|
||||
|
||||
return (
|
||||
<Box component={Paper} className={classes.root}>
|
||||
<InputBase
|
||||
@@ -42,8 +49,11 @@ export const DialerInput = () => {
|
||||
className={classes.input}
|
||||
value={inputVal}
|
||||
/>
|
||||
<IconButton color='primary' className={classes.iconBtn}>
|
||||
<PhoneIcon fontSize="large" onClick={() => handleCall(inputVal)} />
|
||||
</IconButton>
|
||||
<IconButton className={classes.iconBtn}>
|
||||
<PhoneIcon onClick={() => handleCall(inputVal)} />
|
||||
<PersonAddIcon fontSize="large" onClick={() => handleNewContact(inputVal)} />
|
||||
</IconButton>
|
||||
</Box>
|
||||
);
|
||||
|
||||
@@ -9,10 +9,10 @@ import HistoryIcon from '@material-ui/icons/History';
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
root: {
|
||||
width: '100%',
|
||||
backgroundColor: theme.palette.background.default,
|
||||
backgroundColor: theme.palette.background.paper,
|
||||
},
|
||||
icon: {
|
||||
color: '#43a047',
|
||||
color: theme.palette.primary.main,
|
||||
},
|
||||
}));
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import React from 'react';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
import PhoneCallbackIcon from '@material-ui/icons/PhoneCallback';
|
||||
import PhoneForwardedIcon from '@material-ui/icons/PhoneForwarded';
|
||||
import PhoneIcon from '@material-ui/icons/Phone';
|
||||
import PersonAddIcon from '@material-ui/icons/PersonAdd';
|
||||
import { List } from '../../../../ui/components/List';
|
||||
import { ListItem } from '../../../../ui/components/ListItem';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
@@ -10,11 +11,27 @@ import { useContacts } from '../../../contacts/hooks/useContacts';
|
||||
import { ICall } from '../../../../common/typings/call';
|
||||
import dayjs from 'dayjs';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Box, IconButton, ListItemIcon, ListItemText } from '@material-ui/core';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
callForward: {
|
||||
color: theme.palette.success.main,
|
||||
},
|
||||
callBack: {
|
||||
color: theme.palette.error.main,
|
||||
},
|
||||
}));
|
||||
|
||||
export const DialerHistory = ({ calls }) => {
|
||||
const { number } = useSimcard();
|
||||
const { getDisplayByNumber } = useContacts();
|
||||
|
||||
const classes = useStyles();
|
||||
|
||||
const history = useHistory();
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleCall = (phoneNumber) => {
|
||||
@@ -23,8 +40,22 @@ export const DialerHistory = ({ calls }) => {
|
||||
});
|
||||
};
|
||||
|
||||
if (!calls) {
|
||||
return <p>Things are loading or arent here at all</p>;
|
||||
if (!calls?.length) {
|
||||
return (
|
||||
<Box
|
||||
display='flex'
|
||||
justifyContent='center'
|
||||
alignItems='center'
|
||||
paddingTop={35}
|
||||
>
|
||||
<p>
|
||||
You got no friends!
|
||||
<span role='img' aria-label='deal with it'>
|
||||
😎
|
||||
</span>
|
||||
</p>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -34,27 +65,59 @@ export const DialerHistory = ({ calls }) => {
|
||||
<ListItem
|
||||
key={call.id}
|
||||
divider
|
||||
button
|
||||
onClick={() => handleCall(call.receiver)}
|
||||
>
|
||||
<ListItemIcon>
|
||||
{<PhoneForwardedIcon className={classes.callForward} />}
|
||||
</ListItemIcon>
|
||||
|
||||
<ListItemText
|
||||
primary={getDisplayByNumber(call.receiver)}
|
||||
secondary={new Date(call.start).getUTCDate()}
|
||||
secondary={dayjs.unix(call.start).format(t('DATE_TIME_FORMAT'))}
|
||||
/>
|
||||
{<PhoneForwardedIcon />}
|
||||
<IconButton onClick={() => handleCall(call.receiver)}>
|
||||
{<PhoneIcon />}
|
||||
</IconButton>
|
||||
|
||||
{getDisplayByNumber(call.transmitter) === call.transmitter ? (
|
||||
<IconButton
|
||||
onClick={() =>
|
||||
history.push(
|
||||
`/contacts/-1?addNumber=${call.transmitter}&referal=/phone/contacts`
|
||||
)
|
||||
}
|
||||
>
|
||||
{<PersonAddIcon />}
|
||||
</IconButton>
|
||||
) : null}
|
||||
</ListItem>
|
||||
) : (
|
||||
<ListItem
|
||||
key={call.id}
|
||||
divider
|
||||
button
|
||||
onClick={() => handleCall(call.transmitter)}
|
||||
>
|
||||
<ListItemIcon>
|
||||
{<PhoneCallbackIcon className={classes.callBack} />}
|
||||
</ListItemIcon>
|
||||
|
||||
<ListItemText
|
||||
primary={getDisplayByNumber(call.transmitter)}
|
||||
secondary={dayjs.unix(call.start).format(t('DATE_TIME_FORMAT'))}
|
||||
/>
|
||||
{<PhoneCallbackIcon />}
|
||||
<IconButton onClick={() => handleCall(call.transmitter)}>
|
||||
{<PhoneIcon />}
|
||||
</IconButton>
|
||||
|
||||
{getDisplayByNumber(call.transmitter) === call.transmitter ? (
|
||||
<IconButton
|
||||
onClick={() =>
|
||||
history.push(
|
||||
`/contacts/-1?addNumber=${call.transmitter}&referal=/phone/contacts`
|
||||
)
|
||||
}
|
||||
>
|
||||
{<PersonAddIcon />}
|
||||
</IconButton>
|
||||
) : null}
|
||||
</ListItem>
|
||||
)
|
||||
)}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { common, green } from "@material-ui/core/colors";
|
||||
|
||||
export const DIALER_APP_PRIMARY_COLOR = green[600];
|
||||
export const DIALER_APP_TEXT_COLOR = common.white;
|
||||
|
||||
const theme = {
|
||||
palette: {
|
||||
primary: {
|
||||
main: DIALER_APP_PRIMARY_COLOR,
|
||||
dark: green[800],
|
||||
light: green[400],
|
||||
contrastText: DIALER_APP_TEXT_COLOR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default theme;
|
||||
@@ -3,6 +3,6 @@ import { atom } from 'recoil';
|
||||
export const dialState = {
|
||||
history: atom({
|
||||
key: 'dialHistory',
|
||||
default: null,
|
||||
default: [],
|
||||
}),
|
||||
};
|
||||
@@ -5,7 +5,7 @@ interface ICallUI {
|
||||
history: ICall[];
|
||||
}
|
||||
|
||||
export const useDialHistory = (): ICallUI => {
|
||||
export const useDialHistory = (): ICallUI[] => {
|
||||
const history = useRecoilValue(dialState.history);
|
||||
return history;
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
import { createAppThemeProvider } from '../../../os/apps/utils/createAppThemeProvider';
|
||||
import dialerTheme from '../dialer.theme';
|
||||
|
||||
export const DialerThemeProvider = createAppThemeProvider(dialerTheme);
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { useState } from 'react';
|
||||
|
||||
import { AppWrapper } from '../../../ui/components';
|
||||
import { AppContent } from '../../../ui/components/AppContent';
|
||||
@@ -6,12 +6,17 @@ import { useApp } from '../../../os/apps/hooks/useApps';
|
||||
import { useExample } from '../hooks/useExample';
|
||||
import { ExampleThemeProvider } from '../providers/ExampleThemeProvider';
|
||||
import { AppTitle } from '../../../ui/components/AppTitle';
|
||||
import { Button } from '@material-ui/core';
|
||||
import PlayIcon from '@material-ui/icons/PlayArrow';
|
||||
import StopIcon from '@material-ui/icons/Stop';
|
||||
import { Button, IconButton } from '@material-ui/core';
|
||||
import useSound from '../../../os/phone/hooks/useSound';
|
||||
|
||||
export const ExampleApp = () => {
|
||||
// calling the example hook, and we assign the value to a variable
|
||||
const exampleString = useExample();
|
||||
const example = useApp('EXAMPLE');
|
||||
const [soundName, setSound] = useState('pixel.ogg');
|
||||
const { play, playing, stop } = useSound('media/ringtones/' + soundName);
|
||||
return (
|
||||
<ExampleThemeProvider>
|
||||
<AppWrapper>
|
||||
@@ -21,6 +26,12 @@ export const ExampleApp = () => {
|
||||
<Button color='primary'>{example.id}</Button>
|
||||
{/* Here we are using the value in a h3 tag */}
|
||||
<h3>{exampleString}</h3>
|
||||
<IconButton onClick={() => (playing ? stop() : play())}>
|
||||
{playing ? <StopIcon /> : <PlayIcon />}
|
||||
</IconButton>
|
||||
<Button onClick={() => setSound('marimba.ogg')}>
|
||||
Change sound on the fly
|
||||
</Button>
|
||||
</AppContent>
|
||||
</AppWrapper>
|
||||
</ExampleThemeProvider>
|
||||
|
||||
@@ -8,8 +8,8 @@ export const HomeApp = () => {
|
||||
const { apps } = useApps();
|
||||
return (
|
||||
<AppWrapper>
|
||||
<Box width='100%' mt={6} px={1}>
|
||||
{apps && <GridMenu items={apps} />}
|
||||
<Box component="div" mt={6} px={1}>
|
||||
{apps && <GridMenu xs={3} items={apps} />}
|
||||
</Box>
|
||||
</AppWrapper>
|
||||
);
|
||||
|
||||
@@ -12,9 +12,11 @@ const useStyles = makeStyles((theme) => ({
|
||||
mySms: {
|
||||
float: 'right',
|
||||
margin: theme.spacing(1),
|
||||
padding: '6px 12px',
|
||||
padding: '6px 16px',
|
||||
height: 'auto',
|
||||
width: '80%',
|
||||
width: 'auto',
|
||||
minWidth: '60%',
|
||||
maxWidth: '85%',
|
||||
background: theme.palette.background.default,
|
||||
color: theme.palette.text.primary,
|
||||
borderRadius: '20px',
|
||||
@@ -24,7 +26,9 @@ const useStyles = makeStyles((theme) => ({
|
||||
float: 'left',
|
||||
margin: theme.spacing(1),
|
||||
padding: '6px 12px',
|
||||
width: '80%',
|
||||
width: 'auto',
|
||||
minWidth: '60%',
|
||||
maxWidth: '85%',
|
||||
height: 'auto',
|
||||
background: theme.palette.primary.light,
|
||||
color: theme.palette.getContrastText(theme.palette.primary.light),
|
||||
@@ -62,7 +66,7 @@ export const MessageBubble = ({
|
||||
<div>{message.message}</div>
|
||||
)}
|
||||
</Box>
|
||||
<Box textAlign='right'>
|
||||
<Box>
|
||||
<Typography variant='subtitle1' color='secondary'>
|
||||
{isGroupChat && !message.isMine
|
||||
? message.display || message.phone_number
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
#notes-app .Mui-focused::after {
|
||||
border-bottom: 3px solid #f9a825;
|
||||
}
|
||||
|
||||
#notes-app .MuiOutlinedInput-root {
|
||||
border: 2px soild #f9a825;
|
||||
}
|
||||
@@ -4,17 +4,45 @@ import { AppContent } from '../../ui/components/AppContent';
|
||||
import { AppTitle } from '../../ui/components/AppTitle';
|
||||
import { useApp } from '../../os/apps/hooks/useApps';
|
||||
import NoteList from './list/NoteList';
|
||||
|
||||
import { useNotes } from './hooks/useNotes';
|
||||
import { NoteModal } from './modal/NoteModal';
|
||||
import { Fab } from '@material-ui/core';
|
||||
import AddIcon from '@material-ui/icons/Add';
|
||||
|
||||
import { useNoteModal } from './hooks/useNoteModal';
|
||||
import { useNoteDetail } from './hooks/useNoteDetail';
|
||||
|
||||
import useStyles from './notes.styles';
|
||||
import InjectDebugData from '../../os/debug/InjectDebugData';
|
||||
import { NotesThemeProvider } from './providers/NotesThemeProvider';
|
||||
import { Route, useHistory } from 'react-router-dom';
|
||||
|
||||
export const NotesApp = () => {
|
||||
const classes = useStyles();
|
||||
const history = useHistory();
|
||||
const notesApp = useApp('NOTES');
|
||||
const { setDetail } = useNoteDetail();
|
||||
|
||||
const onClickCreate = () => {
|
||||
setDetail({ title: '', content: '' });
|
||||
history.push('/notes/detail');
|
||||
};
|
||||
|
||||
return (
|
||||
<NotesThemeProvider>
|
||||
<AppWrapper id='notes-app'>
|
||||
<AppTitle app={notesApp} />
|
||||
<Route path='/notes/detail' component={NoteModal} />
|
||||
<AppContent>
|
||||
<Route path='/notes' component={NoteList} />
|
||||
<Fab
|
||||
className={classes.absolute}
|
||||
onClick={onClickCreate}
|
||||
color='primary'
|
||||
>
|
||||
<AddIcon />
|
||||
</Fab>
|
||||
</AppContent>
|
||||
</AppWrapper>
|
||||
</NotesThemeProvider>
|
||||
);
|
||||
};
|
||||
|
||||
InjectDebugData([
|
||||
{
|
||||
@@ -34,37 +62,3 @@ InjectDebugData([
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
export const NotesApp = () => {
|
||||
const { setNoteModal } = useNoteModal();
|
||||
const { detail, setDetail } = useNoteDetail();
|
||||
const { notes } = useNotes();
|
||||
const notesApp = useApp('NOTES');
|
||||
|
||||
const classes = useStyles();
|
||||
|
||||
const handleModal = () => {
|
||||
setNoteModal(true);
|
||||
setDetail(null);
|
||||
};
|
||||
|
||||
return (
|
||||
<AppWrapper id='notes-app'>
|
||||
<AppTitle app={notesApp} />
|
||||
<NoteModal key={detail?.id} />
|
||||
<AppContent>
|
||||
<NoteList notes={notes} />
|
||||
</AppContent>
|
||||
<Fab
|
||||
className={classes.absolute}
|
||||
onClick={handleModal}
|
||||
style={{
|
||||
background: '#f9a825',
|
||||
color: '#fff',
|
||||
}}
|
||||
>
|
||||
<AddIcon />
|
||||
</Fab>
|
||||
</AppWrapper>
|
||||
);
|
||||
};
|
||||
@@ -1,18 +1,30 @@
|
||||
import React from 'react';
|
||||
|
||||
import { yellow } from '@material-ui/core/colors';
|
||||
|
||||
import useStyles from './notes.styles';
|
||||
|
||||
import { Paper } from '@material-ui/core';
|
||||
import { makeStyles, Paper } from '@material-ui/core';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faStickyNote } from '@fortawesome/free-solid-svg-icons';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
header: {
|
||||
width: '100%',
|
||||
display: 'flex',
|
||||
flexFlow: 'row nowrap',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
textAlign: 'center',
|
||||
height: '60px',
|
||||
},
|
||||
icon: {
|
||||
color: theme.palette.primary.main,
|
||||
fontSize: 40,
|
||||
},
|
||||
}));
|
||||
|
||||
const NotesTitle = () => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Paper elevation={24} square variant='outlined' className={classes.header}>
|
||||
<FontAwesomeIcon icon={faStickyNote} color={yellow[800]} size='lg' />
|
||||
<FontAwesomeIcon icon={faStickyNote} className={classes.icon} size='lg' />
|
||||
</Paper>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { noteStates } from './state';
|
||||
|
||||
interface NoteModalProps {
|
||||
noteModal: boolean;
|
||||
setNoteModal: (show: boolean) => void;
|
||||
}
|
||||
|
||||
export const useNoteModal = (): NoteModalProps => {
|
||||
const [noteModal, setNoteModal] = useRecoilState(noteStates.noteModal);
|
||||
return { noteModal, setNoteModal };
|
||||
};
|
||||
@@ -1,18 +1,19 @@
|
||||
import { List, ListItem, ListItemText } from '@material-ui/core';
|
||||
import React from 'react';
|
||||
|
||||
import { useNoteModal } from '../hooks/useNoteModal';
|
||||
import { List, ListItem, ListItemText } from '@material-ui/core';
|
||||
import { useNoteDetail } from '../hooks/useNoteDetail';
|
||||
import { useNotes } from '../hooks/useNotes';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
// add search bar later
|
||||
// TODO: Add interface for note
|
||||
const NoteList = ({ notes }) => {
|
||||
const { setNoteModal } = useNoteModal();
|
||||
const NoteList = () => {
|
||||
const history = useHistory();
|
||||
const { notes } = useNotes();
|
||||
const { setDetail } = useNoteDetail();
|
||||
|
||||
const handleNoteModal = (note) => {
|
||||
setNoteModal(true);
|
||||
setDetail(note);
|
||||
history.push('/notes/detail');
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,41 +1,39 @@
|
||||
import { Button, TextField, Slide } from '@material-ui/core';
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
Button,
|
||||
TextField,
|
||||
Slide,
|
||||
Paper,
|
||||
Typography,
|
||||
Container,
|
||||
CircularProgress,
|
||||
Box,
|
||||
} from '@material-ui/core';
|
||||
import React from 'react';
|
||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||
|
||||
import { useNoteModal } from '../hooks/useNoteModal';
|
||||
import { useNoteDetail } from '../hooks/useNoteDetail';
|
||||
|
||||
import useStyles from './modal.styles';
|
||||
|
||||
import '../NotesApp.css';
|
||||
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';
|
||||
|
||||
// TODO: Fix input focus color
|
||||
export const NoteModal = () => {
|
||||
const { noteModal, setNoteModal } = useNoteModal();
|
||||
const classes = useStyles();
|
||||
const history = useHistory();
|
||||
const { t } = useTranslation();
|
||||
const { detail, setDetail } = useNoteDetail();
|
||||
const [title, setTitle] = useState(detail ? detail.title : '');
|
||||
const [content, setContent] = useState(detail ? detail.content : '');
|
||||
|
||||
const classes = useStyles()
|
||||
|
||||
|
||||
const onClose = () => history.goBack();
|
||||
|
||||
const _handleClose = () => {
|
||||
setDetail(null);
|
||||
setNoteModal(false);
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleNoteSave = () => {
|
||||
Nui.send('phone:addNote', {
|
||||
title,
|
||||
content,
|
||||
});
|
||||
Nui.send('phone:addNote', detail);
|
||||
setDetail(null);
|
||||
setNoteModal(false);
|
||||
|
||||
setTitle('')
|
||||
setContent('')
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleDeleteNote = () => {
|
||||
@@ -44,78 +42,112 @@ export const NoteModal = () => {
|
||||
id,
|
||||
});
|
||||
setDetail(null);
|
||||
setNoteModal(false);
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleUpdateNote = () => {
|
||||
Nui.send('phone:updateNote', {
|
||||
id: detail.id,
|
||||
title,
|
||||
content,
|
||||
});
|
||||
Nui.send('phone:updateNote', detail);
|
||||
setDetail(null);
|
||||
setNoteModal(false);
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={noteModal ? classes.modalRoot : classes.modalHide}>
|
||||
<Slide direction='left' in={noteModal} mountOnEnter unmountOnExit>
|
||||
<div>
|
||||
<Button className={classes.closeButton} onClick={_handleClose}>
|
||||
<ArrowBackIcon fontSize='large' />
|
||||
</Button>
|
||||
<div id='notes-modal' className={classes.noteContainer}>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
rowsMax={1}
|
||||
placeholder='Title'
|
||||
inputProps={{
|
||||
className: classes.inputPropsTitle,
|
||||
maxLength: 25
|
||||
}}
|
||||
fullWidth
|
||||
value={title}
|
||||
onChange={(e) => setTitle(e.target.value)}
|
||||
/>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
inputProps={{
|
||||
className: classes.inputPropsContent,
|
||||
maxLength: 250,
|
||||
}}
|
||||
placeholder='Content'
|
||||
multiline
|
||||
fullWidth
|
||||
rows={19}
|
||||
variant='outlined'
|
||||
value={content}
|
||||
onChange={(e) => setContent(e.target.value)}
|
||||
/>
|
||||
<p style={{ color: "#fff" }}>{content.length}/250</p>
|
||||
{!detail &&(
|
||||
<Button disabled={title.length > 0 ? false : true} className={classes.saveButton} onClick={handleNoteSave}>
|
||||
Save
|
||||
</Button>
|
||||
)}
|
||||
{detail && (
|
||||
<Button
|
||||
className={classes.updateButton}
|
||||
onClick={handleUpdateNote}
|
||||
>
|
||||
Update
|
||||
</Button>
|
||||
)}
|
||||
{detail && (
|
||||
<Button
|
||||
className={classes.deleteButton}
|
||||
onClick={handleDeleteNote}
|
||||
>
|
||||
Delete
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Slide>
|
||||
</div>
|
||||
<Slide direction='left' in={!!detail}>
|
||||
<Paper className={classes.modalRoot}>
|
||||
{!detail ? (
|
||||
<CircularProgress />
|
||||
) : (
|
||||
<Container>
|
||||
<Box>
|
||||
<Box py={2}>
|
||||
<Button
|
||||
color='primary'
|
||||
size='large'
|
||||
startIcon={<ArrowBackIcon fontSize='large' />}
|
||||
onClick={_handleClose}
|
||||
>
|
||||
{t('APPS_NOTES')}
|
||||
</Button>
|
||||
</Box>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
rowsMax={1}
|
||||
label={t('GENERIC_TITLE')}
|
||||
inputProps={{
|
||||
className: classes.inputPropsTitle,
|
||||
maxLength: 25,
|
||||
}}
|
||||
fullWidth
|
||||
value={detail.title}
|
||||
onChange={(e) =>
|
||||
setDetail((d) => ({ ...d, title: e.target.value }))
|
||||
}
|
||||
/>
|
||||
<TextField
|
||||
className={classes.input}
|
||||
inputProps={{
|
||||
className: classes.inputPropsContent,
|
||||
maxLength: 250,
|
||||
}}
|
||||
label={t('GENERIC_CONTENT')}
|
||||
multiline
|
||||
fullWidth
|
||||
rows={16}
|
||||
variant='outlined'
|
||||
value={detail.content}
|
||||
onChange={(e) =>
|
||||
setDetail((d) => ({ ...d, content: e.target.value }))
|
||||
}
|
||||
/>
|
||||
<Typography paragraph>{detail.content.length}/250</Typography>
|
||||
{!detail.id ? (
|
||||
<>
|
||||
<Box display="inline" p={1}>
|
||||
<Button
|
||||
color='primary'
|
||||
variant='contained'
|
||||
disabled={detail.title.length > 0 ? false : true}
|
||||
onClick={handleNoteSave}
|
||||
>
|
||||
{t('GENERIC_SAVE')}
|
||||
</Button>
|
||||
</Box>
|
||||
<Box display="inline" p={1}>
|
||||
<StatusButton
|
||||
color='error'
|
||||
variant='contained'
|
||||
onClick={_handleClose}
|
||||
>
|
||||
{t('GENERIC_CANCEL')}
|
||||
</StatusButton>
|
||||
</Box>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Box display="inline" p={1}>
|
||||
<Button
|
||||
color='primary'
|
||||
variant='contained'
|
||||
onClick={handleUpdateNote}
|
||||
>
|
||||
{t('GENERIC_UPDATE')}
|
||||
</Button>
|
||||
</Box>
|
||||
<Box display="inline" p={1}>
|
||||
<StatusButton
|
||||
color='error'
|
||||
variant='contained'
|
||||
onClick={handleDeleteNote}
|
||||
>
|
||||
{t('GENERIC_DELETE')}
|
||||
</StatusButton>
|
||||
</Box>
|
||||
</>
|
||||
)}
|
||||
</Box>
|
||||
</Container>
|
||||
)}
|
||||
</Paper>
|
||||
</Slide>
|
||||
);
|
||||
};
|
||||
@@ -4,23 +4,9 @@ const useStyles = makeStyles((theme) => ({
|
||||
modalRoot: {
|
||||
zIndex: 20,
|
||||
position: 'absolute',
|
||||
height: '100%',
|
||||
height: '99%',
|
||||
width: '100%',
|
||||
background: '#232323',
|
||||
},
|
||||
modalHide: {
|
||||
display: 'none',
|
||||
},
|
||||
closeButton: {
|
||||
width: '10%',
|
||||
position: 'absolute',
|
||||
top: 10,
|
||||
left: 0,
|
||||
},
|
||||
noteContainer: {
|
||||
width: '90%',
|
||||
marginTop: 80,
|
||||
margin: '0 auto',
|
||||
background: theme.palette.background.default,
|
||||
},
|
||||
input: {
|
||||
marginBottom: 20,
|
||||
@@ -30,19 +16,7 @@ const useStyles = makeStyles((theme) => ({
|
||||
},
|
||||
inputPropsContent: {
|
||||
fontSize: 20,
|
||||
},
|
||||
saveButton: {
|
||||
background: '#f9a825',
|
||||
padding: '10px 30px',
|
||||
},
|
||||
updateButton: {
|
||||
background: '#f9a825',
|
||||
padding: '10px 30px',
|
||||
marginRight: '8px',
|
||||
},
|
||||
deleteButton: {
|
||||
background: '#c62828',
|
||||
padding: '10px 30px',
|
||||
lineHeight: 1.2,
|
||||
},
|
||||
}));
|
||||
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
import { makeStyles } from '@material-ui/core';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
header: {
|
||||
width: '100%',
|
||||
display: 'flex',
|
||||
flexFlow: 'row nowrap',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
textAlign: 'center',
|
||||
height: '60px',
|
||||
},
|
||||
backgroundModal: {
|
||||
background: 'black',
|
||||
opacity: '0.6',
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import { common, yellow } from "@material-ui/core/colors";
|
||||
|
||||
export const NOTES_APP_PRIMARY_COLOR = yellow[800];
|
||||
export const NOTES_APP_ICON_COLOR = common.white;
|
||||
export const NOTES_APP_TEXT_COLOR = common.black;
|
||||
|
||||
const theme = {
|
||||
palette: {
|
||||
primary: {
|
||||
main: NOTES_APP_PRIMARY_COLOR,
|
||||
dark: yellow[900],
|
||||
light: yellow[500],
|
||||
contrastText: NOTES_APP_TEXT_COLOR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default theme;
|
||||
@@ -0,0 +1,4 @@
|
||||
import { createAppThemeProvider } from "../../../os/apps/utils/createAppThemeProvider";
|
||||
import notesTheme from '../notes.theme';
|
||||
|
||||
export const NotesThemeProvider = createAppThemeProvider(notesTheme);
|
||||
@@ -1,12 +1,16 @@
|
||||
import { common } from "@material-ui/core/colors";
|
||||
import { common, red } from "@material-ui/core/colors";
|
||||
|
||||
export const SELLOUT_APP_PRIMARY_COLOR = red[500];
|
||||
export const SELLOUT_APP_ICON_COLOR = common.white;
|
||||
export const SELLOUT_APP_TEXT_COLOR = common.black;
|
||||
|
||||
const theme = {
|
||||
palette: {
|
||||
primary: {
|
||||
main: '#f44336',
|
||||
dark: '#b3251b',
|
||||
light: 'f87f76',
|
||||
contrastText: common.black
|
||||
main: SELLOUT_APP_PRIMARY_COLOR,
|
||||
dark: red[700],
|
||||
light: red[200],
|
||||
contrastText: SELLOUT_APP_TEXT_COLOR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,100 +20,6 @@ import { useProfile } from '../hooks/useProfile';
|
||||
import ProfilePrompt from './profile/ProfilePrompt';
|
||||
import InjectDebugData from '../../../os/debug/InjectDebugData';
|
||||
|
||||
InjectDebugData([
|
||||
{
|
||||
app: 'TWITTER',
|
||||
method: 'getOrCreateTwitterProfile',
|
||||
data: {
|
||||
profile_name: 'Angular_Dev',
|
||||
bio: 'Angular FTW',
|
||||
job: 'Googler @ Google',
|
||||
location: '1600 Amphitheatre Parkway, CA, USA',
|
||||
avatar_url: 'https://i.tasoagc.dev/i9Ig',
|
||||
},
|
||||
},
|
||||
{
|
||||
app: 'TWITTER',
|
||||
method: 'createTweetBroadcast',
|
||||
data: {
|
||||
id: 111,
|
||||
profile_id: 111,
|
||||
profile_name: 'Kidz',
|
||||
isMine: false,
|
||||
isReported: false,
|
||||
message: 'I have tweeted this because Im badass'
|
||||
}
|
||||
},
|
||||
{
|
||||
app: 'TWITTER',
|
||||
method: 'createTweetBroadcast',
|
||||
data: {
|
||||
id: 111,
|
||||
profile_id: 111,
|
||||
profile_name: 'ItsChip',
|
||||
isMine: false,
|
||||
isReported: false,
|
||||
message: 'I have tweeted this because Im even more badass'
|
||||
}
|
||||
},
|
||||
{
|
||||
app: 'TWITTER',
|
||||
method: 'fetchTweets',
|
||||
data: [
|
||||
{
|
||||
id: 59,
|
||||
message: 'XSS\n<script src="test.js">Test</script>\nBro',
|
||||
avatar_url: 'http://i.tasoagc.dev/jtKL',
|
||||
seconds_since_tweet: 500,
|
||||
isMine: false,
|
||||
updateAt: '2021-02-08 14:37:46',
|
||||
visible: 1,
|
||||
likes: 50000,
|
||||
profile_name: 'jQuery Main',
|
||||
images: 'http://i.tasoagc.dev/0xdp',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
message: 'GCPhone will never die',
|
||||
avatar_url: 'http://i.tasoagc.dev/jtKL',
|
||||
seconds_since_tweet: 500,
|
||||
isMine: false,
|
||||
updateAt: '2021-02-08 14:37:46',
|
||||
visible: 1,
|
||||
likes: 50000,
|
||||
profile_name: 'GCPhone_v9999',
|
||||
images: 'http://i.tasoagc.dev/0xdp',
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
message: 'I love angular',
|
||||
avatar_url: 'https://i.tasoagc.dev/i9Ig',
|
||||
seconds_since_tweet: 800,
|
||||
isMine: true,
|
||||
updateAt: '2021-02-08 14:37:46',
|
||||
visible: 1,
|
||||
likes: 50000,
|
||||
profile_name: 'Angular_Dev',
|
||||
images: 'http://i.tasoagc.dev/i9Ig',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
message:
|
||||
'Anyways uhm... I bought a whole bunch of shungite, rocks, ' +
|
||||
'do you know what shungite is? Anybody know what shungite is. No, no ' +
|
||||
'Suge Knight, I think hes locked up in prison.',
|
||||
avatar_url: 'http://i.tasoagc.dev/0v64',
|
||||
seconds_since_tweet: 800,
|
||||
isMine: true,
|
||||
updateAt: '2021-02-08 14:37:46',
|
||||
visible: 1,
|
||||
likes: 50000,
|
||||
profile_name: 'The_Doc',
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
const useStyles = makeStyles(() => ({
|
||||
backgroundModal: {
|
||||
background: 'black',
|
||||
@@ -186,3 +92,103 @@ export const TwitterApp = () => {
|
||||
</AppWrapper>
|
||||
);
|
||||
};
|
||||
|
||||
InjectDebugData([
|
||||
{
|
||||
app: 'TWITTER',
|
||||
method: 'getOrCreateTwitterProfile',
|
||||
data: {
|
||||
profile_name: 'Angular_Dev',
|
||||
bio: 'Angular FTW',
|
||||
job: 'Googler @ Google',
|
||||
location: '1600 Amphitheatre Parkway, CA, USA',
|
||||
avatar_url: 'https://i.tasoagc.dev/i9Ig',
|
||||
},
|
||||
},
|
||||
{
|
||||
app: 'TWITTER',
|
||||
method: 'fetchTweets',
|
||||
data: [
|
||||
{
|
||||
id: 59,
|
||||
message: 'XSS\n<script src="test.js">Test</script>\nBro',
|
||||
avatar_url: 'http://i.tasoagc.dev/jtKL',
|
||||
seconds_since_tweet: 500,
|
||||
isMine: false,
|
||||
updateAt: '2021-02-08 14:37:46',
|
||||
visible: 1,
|
||||
likes: 50000,
|
||||
profile_name: 'jQuery Main',
|
||||
images: 'http://i.tasoagc.dev/0xdp',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
message: 'GCPhone will never die',
|
||||
avatar_url: 'http://i.tasoagc.dev/jtKL',
|
||||
seconds_since_tweet: 500,
|
||||
isMine: false,
|
||||
updateAt: '2021-02-08 14:37:46',
|
||||
visible: 1,
|
||||
likes: 50000,
|
||||
profile_name: 'GCPhone_v9999',
|
||||
images: 'http://i.tasoagc.dev/0xdp',
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
message: 'I love angular',
|
||||
avatar_url: 'https://i.tasoagc.dev/i9Ig',
|
||||
seconds_since_tweet: 800,
|
||||
isMine: true,
|
||||
updateAt: '2021-02-08 14:37:46',
|
||||
visible: 1,
|
||||
likes: 50000,
|
||||
profile_name: 'Angular_Dev',
|
||||
images: 'http://i.tasoagc.dev/i9Ig',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
message:
|
||||
'Anyways uhm... I bought a whole bunch of shungite, rocks, ' +
|
||||
'do you know what shungite is? Anybody know what shungite is. No, no ' +
|
||||
'Suge Knight, I think hes locked up in prison.',
|
||||
avatar_url: 'http://i.tasoagc.dev/0v64',
|
||||
seconds_since_tweet: 800,
|
||||
isMine: true,
|
||||
updateAt: '2021-02-08 14:37:46',
|
||||
visible: 1,
|
||||
likes: 50000,
|
||||
profile_name: 'The_Doc',
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
InjectDebugData(
|
||||
[
|
||||
{
|
||||
app: 'TWITTER',
|
||||
method: 'createTweetBroadcast',
|
||||
data: {
|
||||
id: 111,
|
||||
profile_id: 111,
|
||||
profile_name: 'Kidz',
|
||||
isMine: false,
|
||||
isReported: false,
|
||||
message: 'I have tweeted this because Im badass',
|
||||
},
|
||||
},
|
||||
{
|
||||
app: 'TWITTER',
|
||||
method: 'createTweetBroadcast',
|
||||
data: {
|
||||
id: 111,
|
||||
profile_id: 111,
|
||||
profile_name: 'ItsChip',
|
||||
isMine: false,
|
||||
isReported: false,
|
||||
message: 'I have tweeted this because Im even more badass... And I need this to be longer so I will continue to write',
|
||||
},
|
||||
},
|
||||
],
|
||||
2000
|
||||
);
|
||||
@@ -2,15 +2,23 @@ import React, { useEffect } from 'react';
|
||||
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { useTweets } from '../../hooks/useTweets';
|
||||
import { useTwitterNotifications } from '../../hooks/useTwitterNotifications';
|
||||
import TweetList from './TweetList';
|
||||
|
||||
export function TweetListContainer() {
|
||||
const { tweets } = useTweets();
|
||||
const { setUnreadCount } = useTwitterNotifications();
|
||||
|
||||
useEffect(() => {
|
||||
Nui.send('phone:fetchTweets', {});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (tweets?.length) {
|
||||
setUnreadCount(0);
|
||||
}
|
||||
}, [setUnreadCount, tweets]);
|
||||
|
||||
return <TweetList tweets={tweets} />;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ export const twitterState = {
|
||||
key: 'updateProfileSuccess',
|
||||
default: null,
|
||||
}),
|
||||
notification: atom({
|
||||
key: 'notification',
|
||||
default: null,
|
||||
unreadTweetsCount: atom({
|
||||
key: 'unreadTweetsCount',
|
||||
default: 0,
|
||||
}),
|
||||
};
|
||||
@@ -1,13 +0,0 @@
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { Tweet } from '../../../common/typings/twitter';
|
||||
import { twitterState } from './state';
|
||||
|
||||
interface ITwitterNotification {
|
||||
notification: Tweet | null;
|
||||
}
|
||||
|
||||
export const useTwitterNotification = (): ITwitterNotification => {
|
||||
const notification = useRecoilValue<Tweet | null>(twitterState.notification);
|
||||
return { notification };
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
import { useCallback } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useHistory } from "react-router-dom";
|
||||
import { useRecoilState } from "recoil";
|
||||
import { useApp } from "../../../os/apps/hooks/useApps";
|
||||
import { useNotifications } from "../../../os/notifications/hooks/useNotifications";
|
||||
import { twitterState } from "./state";
|
||||
|
||||
export const useTwitterNotifications = () => {
|
||||
const { t } = useTranslation();
|
||||
const history = useHistory();
|
||||
const { addNotificationAlert } = useNotifications();
|
||||
const { icon, notificationIcon } = useApp('TWITTER');
|
||||
const [unreadCount, setUnreadCount] = useRecoilState(twitterState.unreadTweetsCount);
|
||||
const setNotification = useCallback(
|
||||
({ profile_name, message }) => {
|
||||
setUnreadCount((curr) => {
|
||||
const unread = curr + 1;
|
||||
addNotificationAlert(
|
||||
{
|
||||
app: 'TWITTER',
|
||||
title: t('APPS_TWITTER_NEW_BROADCAST', { profile_name }),
|
||||
onClick: () => history.push('/twitter'),
|
||||
content: message,
|
||||
icon,
|
||||
notificationIcon,
|
||||
},
|
||||
true,
|
||||
{
|
||||
title: t('APPS_TWITTER_UNREAD_MESSAGES', {
|
||||
count: unread,
|
||||
}),
|
||||
content: null,
|
||||
}
|
||||
);
|
||||
return unread;
|
||||
});
|
||||
},
|
||||
[setUnreadCount, addNotificationAlert, t, icon, notificationIcon, history]
|
||||
);
|
||||
|
||||
return { setNotification, setUnreadCount, unreadCount }
|
||||
};
|
||||
@@ -5,11 +5,8 @@ import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent';
|
||||
import { IMAGE_DELIMITER } from '../utils/images';
|
||||
import { APP_TWITTER } from '../utils/constants';
|
||||
import { twitterState } from './state';
|
||||
import { useNotifications } from '../../../os/notifications/hooks/useNotifications';
|
||||
import { useApp } from '../../../os/apps/hooks/useApps';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useCallback } from 'react';
|
||||
import { useSnackbar } from '../../../ui/hooks/useSnackbar';
|
||||
import { useTwitterNotifications } from './useTwitterNotifications';
|
||||
|
||||
/**
|
||||
* Perform all necessary processing/transforms from the raw database
|
||||
@@ -33,23 +30,8 @@ function processTweet(tweet) {
|
||||
* there and have moved that logic here instead.
|
||||
*/
|
||||
export const useTwitterService = () => {
|
||||
const { t } = useTranslation();
|
||||
const { addNotification } = useNotifications();
|
||||
const { addAlert } = useSnackbar()
|
||||
const { icon, notificationIcon } = useApp('TWITTER');
|
||||
|
||||
const setNotification = useCallback(
|
||||
({ profile_name, message }) =>
|
||||
addNotification({
|
||||
app: 'TWITTER',
|
||||
title: t('APPS_TWITTER_NEW_BROADCAST', { profile_name }),
|
||||
href: '/twitter',
|
||||
content: message,
|
||||
icon,
|
||||
notificationIcon,
|
||||
}),
|
||||
[addNotification, icon, notificationIcon, t]
|
||||
);
|
||||
const { setNotification } = useTwitterNotifications();
|
||||
|
||||
const setProfile = useSetRecoilState(twitterState.profile);
|
||||
const setUpdateProfileLoading = useSetRecoilState(
|
||||
|
||||
Reference in new issue
Block a user