mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-25 16:40:58 -05:00
Fix enter key sending message while still composing
This commit is contained in:
parent
2ff9c91287
commit
5b16977b0e
1 changed files with 21 additions and 20 deletions
|
@ -48,11 +48,11 @@ export type UploadState =
|
||||||
| { type: "none" }
|
| { type: "none" }
|
||||||
| { type: "attached"; files: File[] }
|
| { type: "attached"; files: File[] }
|
||||||
| {
|
| {
|
||||||
type: "uploading";
|
type: "uploading";
|
||||||
files: File[];
|
files: File[];
|
||||||
percent: number;
|
percent: number;
|
||||||
cancel: CancelTokenSource;
|
cancel: CancelTokenSource;
|
||||||
}
|
}
|
||||||
| { type: "sending"; files: File[] }
|
| { type: "sending"; files: File[] }
|
||||||
| { type: "failed"; files: File[]; error: string };
|
| { type: "failed"; files: File[]; error: string };
|
||||||
|
|
||||||
|
@ -173,9 +173,9 @@ export default observer(({ channel }: Props) => {
|
||||||
const text =
|
const text =
|
||||||
action === "quote"
|
action === "quote"
|
||||||
? `${content
|
? `${content
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.map((x) => `> ${x}`)
|
.map((x) => `> ${x}`)
|
||||||
.join("\n")}\n\n`
|
.join("\n")}\n\n`
|
||||||
: `${content} `;
|
: `${content} `;
|
||||||
|
|
||||||
if (!draft || draft.length === 0) {
|
if (!draft || draft.length === 0) {
|
||||||
|
@ -225,8 +225,8 @@ export default observer(({ channel }: Props) => {
|
||||||
toReplace == ""
|
toReplace == ""
|
||||||
? msg.content.toString() + newText
|
? msg.content.toString() + newText
|
||||||
: msg.content
|
: msg.content
|
||||||
.toString()
|
.toString()
|
||||||
.replace(new RegExp(toReplace, flags), newText);
|
.replace(new RegExp(toReplace, flags), newText);
|
||||||
|
|
||||||
if (newContent != msg.content) {
|
if (newContent != msg.content) {
|
||||||
if (newContent.length == 0) {
|
if (newContent.length == 0) {
|
||||||
|
@ -305,10 +305,10 @@ export default observer(({ channel }: Props) => {
|
||||||
files,
|
files,
|
||||||
percent: Math.round(
|
percent: Math.round(
|
||||||
(i * 100 + (100 * e.loaded) / e.total) /
|
(i * 100 + (100 * e.loaded) / e.total) /
|
||||||
Math.min(
|
Math.min(
|
||||||
files.length,
|
files.length,
|
||||||
CAN_UPLOAD_AT_ONCE,
|
CAN_UPLOAD_AT_ONCE,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
cancel,
|
cancel,
|
||||||
}),
|
}),
|
||||||
|
@ -523,6 +523,7 @@ export default observer(({ channel }: Props) => {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!e.shiftKey &&
|
!e.shiftKey &&
|
||||||
|
!e.isComposing &&
|
||||||
e.key === "Enter" &&
|
e.key === "Enter" &&
|
||||||
!isTouchscreenDevice
|
!isTouchscreenDevice
|
||||||
) {
|
) {
|
||||||
|
@ -552,13 +553,13 @@ export default observer(({ channel }: Props) => {
|
||||||
placeholder={
|
placeholder={
|
||||||
channel.channel_type === "DirectMessage"
|
channel.channel_type === "DirectMessage"
|
||||||
? translate("app.main.channel.message_who", {
|
? translate("app.main.channel.message_who", {
|
||||||
person: channel.recipient?.username,
|
person: channel.recipient?.username,
|
||||||
})
|
})
|
||||||
: channel.channel_type === "SavedMessages"
|
: channel.channel_type === "SavedMessages"
|
||||||
? translate("app.main.channel.message_saved")
|
? translate("app.main.channel.message_saved")
|
||||||
: translate("app.main.channel.message_where", {
|
: translate("app.main.channel.message_where", {
|
||||||
channel_name: channel.name ?? undefined,
|
channel_name: channel.name ?? undefined,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
disabled={
|
disabled={
|
||||||
uploadState.type === "uploading" ||
|
uploadState.type === "uploading" ||
|
||||||
|
|
Loading…
Reference in a new issue