Continued work on the send dialog

This commit is contained in:
Philipp Heckel 2022-03-29 15:22:26 -04:00
parent b6426f0417
commit 3e121f5d3c
7 changed files with 212 additions and 98 deletions

View file

@ -127,15 +127,24 @@ const Main = (props) => {
const Sender = (props) => {
const [message, setMessage] = useState("");
const [sendDialogKey, setSendDialogKey] = useState(0);
const [sendDialogOpen, setSendDialogOpen] = useState(false);
const subscription = props.selected;
const handleSendClick = () => {
api.publish(subscription.baseUrl, subscription.topic, message);
api.publish(subscription.baseUrl, subscription.topic, message); // FIXME
setMessage("");
};
const handleSendDialogClose = () => {
setSendDialogOpen(false);
setSendDialogKey(prev => prev+1);
};
if (!props.selected) {
return null;
}
return (
<Paper
elevation={3}
@ -172,8 +181,9 @@ const Sender = (props) => {
<SendIcon/>
</IconButton>
<SendDialog
key={`sendDialog${sendDialogKey}`} // Resets dialog when canceled/closed
open={sendDialogOpen}
onCancel={() => setSendDialogOpen(false)}
onClose={handleSendDialogClose}
topicUrl={topicUrl(subscription.baseUrl, subscription.topic)}
message={message}
/>