if (document.hasFocus()) {
scrollToBottomRef.current.count += 1;
scrollToBottomRef.current.smooth = true;
+ } else if (!unreadInfo) {
+ setUnreadInfo(getRoomUnreadInfo(room));
}
setTimeline((ct) => ({
...ct,
if (!replyEvt) return;
const editedReply = getEditedEvent(replyId, replyEvt, room.getUnfilteredTimelineSet());
const { body, formatted_body: formattedBody }: Record<string, string> =
- editedReply?.getContent()['m.new.content'] ?? replyEvt.getContent();
+ editedReply?.getContent()['m.new_content'] ?? replyEvt.getContent();
const senderId = replyEvt.getSender();
if (senderId && typeof body === 'string') {
setReplyDraft({
renderText: (mEventId, mEvent, timelineSet) => {
const editedEvent = getEditedEvent(mEventId, mEvent, timelineSet);
const { body, formatted_body: customBody }: Record<string, unknown> =
- editedEvent?.getContent()['m.new.content'] ?? mEvent.getContent();
+ editedEvent?.getContent()['m.new_content'] ?? mEvent.getContent();
if (typeof body !== 'string') return null;
return (
renderEmote: (mEventId, mEvent, timelineSet) => {
const editedEvent = getEditedEvent(mEventId, mEvent, timelineSet);
const { body, formatted_body: customBody } =
- editedEvent?.getContent()['m.new.content'] ?? mEvent.getContent();
+ editedEvent?.getContent()['m.new_content'] ?? mEvent.getContent();
const senderId = mEvent.getSender() ?? '';
const senderDisplayName =
renderNotice: (mEventId, mEvent, timelineSet) => {
const editedEvent = getEditedEvent(mEventId, mEvent, timelineSet);
const { body, formatted_body: customBody }: Record<string, unknown> =
- editedEvent?.getContent()['m.new.content'] ?? mEvent.getContent();
+ editedEvent?.getContent()['m.new_content'] ?? mEvent.getContent();
if (typeof body !== 'string') return null;
return (
const [autocompleteQuery, setAutocompleteQuery] =
useState<AutocompleteQuery<AutocompletePrefix>>();
- const getPrevBodyAndFormattedBody = useCallback(() => {
+ const getPrevBodyAndFormattedBody = useCallback((): [
+ string | undefined,
+ string | undefined
+ ] => {
const evtId = mEvent.getId()!;
const evtTimeline = room.getTimelineForEvent(evtId);
const editedEvent =
evtTimeline && getEditedEvent(evtId, mEvent, evtTimeline.getTimelineSet());
const { body, formatted_body: customHtml }: Record<string, unknown> =
- editedEvent?.getContent()['m.new.content'] ?? mEvent.getContent();
+ editedEvent?.getContent()['m.new_content'] ?? mEvent.getContent();
- return [body, customHtml];
+ return [
+ typeof body === 'string' ? body : undefined,
+ typeof customHtml === 'string' ? customHtml : undefined,
+ ];
}, [room, mEvent]);
const [saveState, save] = useAsyncCallback(
const [prevBody, prevCustomHtml] = getPrevBodyAndFormattedBody();
if (plainText === '') return undefined;
- if (
- typeof prevCustomHtml === 'string' &&
- trimReplyFromFormattedBody(prevCustomHtml) === customHtml
- ) {
- return undefined;
- }
- if (!prevCustomHtml && typeof prevBody === 'string' && prevBody === plainText) {
- return undefined;
+ if (prevBody) {
+ if (prevCustomHtml && trimReplyFromFormattedBody(prevCustomHtml) === customHtml) {
+ return undefined;
+ }
+ if (
+ !prevCustomHtml &&
+ prevBody === plainText &&
+ customHtmlEqualsPlainText(customHtml, plainText)
+ ) {
+ return undefined;
+ }
}
const newContent: IContent = {