mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
Fix sharing bug
This commit is contained in:
1 parent
ecd826dcd3
commit
1db4dafa2d
2 files changed
+38
-13
No files matched your search
@@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { useCalculator, CalcButton } from '../hooks/useCalculator';
|
import { useCalculator, CalcButton } from '../hooks/useCalculator';
|
||||||
import { Grid, makeStyles, Box, Paper } from '@material-ui/core';
|
import { Grid, makeStyles, Box, Paper, Fab } from '@material-ui/core';
|
||||||
|
import { setClipboard } from '../../../os/phone/hooks/useClipboard';
|
||||||
|
import FileCopyIcon from '@material-ui/icons/FileCopy';
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
button: {
|
button: {
|
||||||
@@ -12,6 +14,12 @@ const useStyles = makeStyles((theme) => ({
|
|||||||
textAlign: 'right',
|
textAlign: 'right',
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
textOverflow: 'ellipsis',
|
textOverflow: 'ellipsis',
|
||||||
|
position: 'relative',
|
||||||
|
},
|
||||||
|
copyFab: {
|
||||||
|
position: 'absolute',
|
||||||
|
top: '16px',
|
||||||
|
left: '16px',
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -38,13 +46,22 @@ export const Calculator = ({ ...props }) => {
|
|||||||
nine,
|
nine,
|
||||||
} = useCalculator();
|
} = useCalculator();
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
const resultStr = useMemo(
|
||||||
|
() =>
|
||||||
|
result().toLocaleString(undefined, {
|
||||||
|
minimumFractionDigits: 0,
|
||||||
|
maximumFractionDigits: 4,
|
||||||
|
}),
|
||||||
|
[result]
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box display='flex' flexDirection='column'>
|
<Box display='flex' flexDirection='column'>
|
||||||
<Box flexGrow={1} component={Paper} p={4} className={classes.result}>
|
<Box flexGrow={1} component={Paper} p={4} className={classes.result}>
|
||||||
{result().toLocaleString(undefined, {
|
<Fab size="small" onClick={() => setClipboard(resultStr)} className={classes.copyFab}>
|
||||||
minimumFractionDigits: 0,
|
<FileCopyIcon />
|
||||||
maximumFractionDigits: 4,
|
</Fab>
|
||||||
})}
|
{resultStr}
|
||||||
</Box>
|
</Box>
|
||||||
<Box>
|
<Box>
|
||||||
<Grid container justify='space-around'>
|
<Grid container justify='space-around'>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||||
import qs from 'qs';
|
import qs from 'qs';
|
||||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||||
|
import CloseIcon from '@material-ui/icons/Close';
|
||||||
import Modal from '../../../../ui/components/Modal';
|
import Modal from '../../../../ui/components/Modal';
|
||||||
import PhotoLibraryIcon from '@material-ui/icons/PhotoLibrary';
|
import PhotoLibraryIcon from '@material-ui/icons/PhotoLibrary';
|
||||||
import { Box, Button, TextField, Typography } from '@material-ui/core';
|
import { Box, Button, TextField, Typography } from '@material-ui/core';
|
||||||
@@ -32,6 +33,11 @@ export const MessageImageModal = ({
|
|||||||
const [pasteVisible, setPasteVisible] = useState(false);
|
const [pasteVisible, setPasteVisible] = useState(false);
|
||||||
const [queryParamImagePreview, setQueryParamImagePreview] = useState(null);
|
const [queryParamImagePreview, setQueryParamImagePreview] = useState(null);
|
||||||
|
|
||||||
|
const removeQueryParamImage = useCallback(() => {
|
||||||
|
setQueryParamImagePreview(null);
|
||||||
|
history.replace(deleteQueryFromLocation({ pathname, search }, 'image'));
|
||||||
|
}, [history, pathname, search]);
|
||||||
|
|
||||||
const sendImageMessage = useCallback(
|
const sendImageMessage = useCallback(
|
||||||
(m) => {
|
(m) => {
|
||||||
Nui.send('phone:sendMessage', {
|
Nui.send('phone:sendMessage', {
|
||||||
@@ -45,13 +51,10 @@ export const MessageImageModal = ({
|
|||||||
|
|
||||||
const sendFromQueryParam = useCallback(
|
const sendFromQueryParam = useCallback(
|
||||||
(image) => {
|
(image) => {
|
||||||
setQueryParamImagePreview(null);
|
|
||||||
sendImageMessage(image);
|
sendImageMessage(image);
|
||||||
|
removeQueryParamImage();
|
||||||
console.log('++++', { pathname, search });
|
|
||||||
history.replace(deleteQueryFromLocation({ pathname, search }, 'image'));
|
|
||||||
},
|
},
|
||||||
[history, pathname, search, sendImageMessage]
|
[removeQueryParamImage, sendImageMessage]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -82,8 +85,13 @@ export const MessageImageModal = ({
|
|||||||
})}`
|
})}`
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Cancel',
|
||||||
|
icon: <CloseIcon />,
|
||||||
|
onClick: onClose,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
[history, pathname, search]
|
[onClose, history, pathname, search]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -91,7 +99,7 @@ export const MessageImageModal = ({
|
|||||||
<ContextMenu open={isOpen} options={menuOptions} onClose={onClose} />
|
<ContextMenu open={isOpen} options={menuOptions} onClose={onClose} />
|
||||||
<Modal
|
<Modal
|
||||||
visible={queryParamImagePreview}
|
visible={queryParamImagePreview}
|
||||||
handleClose={() => setQueryParamImagePreview(null)}
|
handleClose={removeQueryParamImage}
|
||||||
>
|
>
|
||||||
<Box py={1}>
|
<Box py={1}>
|
||||||
<Typography paragraph>Do you want to share this image?</Typography>
|
<Typography paragraph>Do you want to share this image?</Typography>
|
||||||
|
|||||||
Reference in new issue
Block a user