mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
set message on enter
This commit is contained in:
parent
f01dab52b6
commit
43d88b5a64
@ -27,12 +27,21 @@ export function AddTopic() {
|
|||||||
actions.addTopic();
|
actions.addTopic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onKey = (e) => {
|
||||||
|
if (e.key === 'Enter' && !e.shiftKey) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (state.messageText) {
|
||||||
|
actions.addTopic();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AddTopicWrapper>
|
<AddTopicWrapper>
|
||||||
<div class="container noselect">
|
<div class="container noselect">
|
||||||
<AddCarousel state={state} actions={actions} />
|
<AddCarousel state={state} actions={actions} />
|
||||||
<div class="input">
|
<div class="input">
|
||||||
<Input.TextArea placeholder="Message" autoSize={{ minRows: 2, maxRows: 6 }}
|
<Input.TextArea placeholder="Message" autoSize={{ minRows: 2, maxRows: 6 }} onKeyPress={onKey}
|
||||||
onChange={(e) => actions.setMessageText(e.target.value)} value={state.messageText} />
|
onChange={(e) => actions.setMessageText(e.target.value)} value={state.messageText} />
|
||||||
</div>
|
</div>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
|
@ -64,6 +64,7 @@ export function useAddTopic() {
|
|||||||
else {
|
else {
|
||||||
await addChannelTopic(app.state.token, channel, message, []);
|
await addChannelTopic(app.state.token, channel, message, []);
|
||||||
}
|
}
|
||||||
|
updateState({ messageText: null, messageColor: null, messageSize: null, backgroundColor: null });
|
||||||
}
|
}
|
||||||
catch(err) {
|
catch(err) {
|
||||||
window.alert(err);
|
window.alert(err);
|
||||||
|
Loading…
Reference in New Issue
Block a user