Skip to content

Commit 427e813

Browse files
committed
fix #7930 -- chat: sometimes when you try to edit the message you just wrote, it is blank
1 parent b94d7a7 commit 427e813

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/packages/frontend/chat/input.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export default function ChatInput({
6767
[],
6868
);
6969

70-
const [input, setInput] = useState<string>(() => {
70+
const [input, setInput] = useState<string>("");
71+
useEffect(() => {
7172
const dbInput = syncdb
7273
?.get_one({
7374
event: "draft",
@@ -79,9 +80,9 @@ export default function ChatInput({
7980
// the db version is used when you refresh your browser while editing, or scroll up and down
8081
// thus unmounting and remounting the currently editing message (due to virtualization).
8182
// See https://github.com/sagemathinc/cocalc/issues/6415
82-
const input = dbInput ?? propsInput;
83-
return input;
84-
});
83+
setInput(dbInput ?? propsInput);
84+
}, [date, sender_id, propsInput]);
85+
8586
const currentInputRef = useRef<string>(input);
8687
const saveOnUnmountRef = useRef<boolean>(true);
8788

src/packages/frontend/chat/message.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,10 @@ const DELETE_BUTTON = false;
5454
const BLANK_COLUMN = (xs) => <Col key={"blankcolumn"} xs={xs}></Col>;
5555

5656
const MARKDOWN_STYLE = undefined;
57-
// const MARKDOWN_STYLE = { maxHeight: "300px", overflowY: "auto" };
5857

5958
const BORDER = "2px solid #ccc";
6059

61-
const SHOW_EDIT_BUTTON_MS = 45000;
60+
const SHOW_EDIT_BUTTON_MS = 15000;
6261

6362
const TRHEAD_STYLE_SINGLE: CSS = {
6463
marginLeft: "15px",
@@ -448,7 +447,13 @@ export default function Message(props: Readonly<Props>) {
448447
<Space direction="horizontal" size="small" wrap>
449448
{showEditButton ? (
450449
<Tooltip
451-
title="Edit this message. You can edit any past message by anybody at any time by double clicking on it. Previous versions are in the history."
450+
title={
451+
<>
452+
Edit this message. You can edit <b>any</b> past message at
453+
any time by double clicking on it. Fix other people's typos.
454+
All versions are stored.
455+
</>
456+
}
452457
placement="left"
453458
>
454459
<Button
@@ -613,7 +618,7 @@ export default function Message(props: Readonly<Props>) {
613618
<Icon
614619
name="thumbs-up"
615620
style={{
616-
color: showOtherFeedback ? "darkred" : undefined,
621+
color: showOtherFeedback ? "darkblue" : undefined,
617622
}}
618623
/>
619624
</Button>
@@ -627,7 +632,6 @@ export default function Message(props: Readonly<Props>) {
627632
size="small"
628633
type={"text"}
629634
style={{
630-
marginRight: "5px",
631635
float: "right",
632636
marginTop: "-4px",
633637
color: is_viewers_message ? "white" : "#888",

0 commit comments

Comments
 (0)