Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion app/markdown/lib/parser/marked/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export const marked = (message, {
smartLists,
smartypants,
renderer,
sanitize: true,
highlight,
});

Expand Down
3 changes: 1 addition & 2 deletions app/ui/client/views/app/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ Meteor.startup(() => {
}
};

this.sendToBottomIfNecessaryDebounced = () => {};
this.sendToBottomIfNecessaryDebounced = _.debounce(this.sendToBottomIfNecessary, 10);
}); // Update message to re-render DOM

Template.roomOld.onDestroyed(function() {
Expand Down Expand Up @@ -820,7 +820,6 @@ Meteor.startup(() => {
template.atBottom = template.isAtBottom(100);
};

template.sendToBottomIfNecessaryDebounced = _.debounce(template.sendToBottomIfNecessary, 150);

if (window.MutationObserver) {
template.observer = new MutationObserver(() => template.sendToBottomIfNecessaryDebounced());
Expand Down
6 changes: 5 additions & 1 deletion client/components/Message/Attachments/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { FC, memo } from 'react';
import { QuoteAttachment, QuoteAttachmentProps } from './QuoteAttachment';
import { FileAttachmentProps, isFileAttachment, FileAttachment } from './Files';
import { DefaultAttachment, DefaultAttachmentProps } from './DefaultAttachment';
import { useBlockRendered } from '../hooks/useBlockRendered';

export type FileProp = {
_id: string;
Expand All @@ -28,6 +29,9 @@ const Item: FC<{attachment: AttachmentProps; file?: FileProp }> = memo(({ attach
return <DefaultAttachment {...attachment as any}/>;
});

const Attachments: FC<{ attachments: Array<AttachmentProps>; file?: FileProp}> = ({ attachments = null, file }): any => attachments && attachments.map((attachment, index) => <Item key={index} file={file} attachment={attachment} />);
const Attachments: FC<{ attachments: Array<AttachmentProps>; file?: FileProp}> = ({ attachments = null, file }): any => {
const { className, ref } = useBlockRendered();
return <><div className={className} ref={ref as any} />{attachments && attachments.map((attachment, index) => <Item key={index} file={file} attachment={attachment} />)}</>;
};

export default Attachments;
4 changes: 4 additions & 0 deletions client/components/Message/Metrics/Broadcast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { FC } from 'react';

import { useTranslation } from '../../../contexts/TranslationContext';
import { Reply, Content } from '..';
import { useBlockRendered } from '../hooks/useBlockRendered';


type BroadcastOptions = {
Expand All @@ -12,7 +13,10 @@ type BroadcastOptions = {

const BroadcastMetric: FC<BroadcastOptions> = ({ username, mid, replyBroadcast }) => {
const t = useTranslation();
const { className, ref } = useBlockRendered();

return <Content>
<div className={className} ref={ref as any} />
<Reply data-username={username} data-mid={mid} onClick={replyBroadcast}>{t('Reply')}</Reply>
</Content>;
};
Expand Down
4 changes: 4 additions & 0 deletions client/components/Message/Metrics/Discussion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { FC } from 'react';
import { useTranslation } from '../../../contexts/TranslationContext';
import { useTimeAgo } from '../../../hooks/useTimeAgo';
import Metrics, { Reply, Content } from '..';
import { useBlockRendered } from '../hooks/useBlockRendered';


type DicussionOptions = {
Expand All @@ -16,7 +17,10 @@ type DicussionOptions = {
const DiscussionMetric: FC<DicussionOptions> = ({ lm, count, rid, drid, openDiscussion }) => {
const t = useTranslation();
const format = useTimeAgo();
const { className, ref } = useBlockRendered();

return <Content>
<div className={className} ref={ref as any} />
<Reply data-rid={rid} data-drid={drid} onClick={openDiscussion}>{count ? t('message_counter', { counter: count, count }) : t('Reply')}</Reply>
<Metrics>
<Metrics.Item title={lm?.toLocaleString()}>
Expand Down
4 changes: 4 additions & 0 deletions client/components/Message/Metrics/Thread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useTimeAgo } from '../../../hooks/useTimeAgo';
import * as NotificationStatus from '../NotificationStatus';
import { followStyle, anchor } from '../helpers/followSyle';
import Metrics, { Reply, Content } from '..';
import { useBlockRendered } from '../hooks/useBlockRendered';


type ThreadReplyOptions = {
Expand All @@ -24,13 +25,16 @@ type ThreadReplyOptions = {
const ThreadMetric: FC<ThreadReplyOptions> = ({ unread, mention, all, rid, mid, counter, participants, following, lm, openThread }) => {
const t = useTranslation();

const { className, ref } = useBlockRendered();

const followMessage = useEndpoint('POST', 'chat.followMessage');
const unfollowMessage = useEndpoint('POST', 'chat.unfollowMessage');
const format = useTimeAgo();

const handleFollow = useCallback(() => (following ? unfollowMessage({ mid }) : followMessage({ mid })), [followMessage, following, mid, unfollowMessage]);

return <Content className={followStyle}>
<div className={className} ref={ref as any} />
<Reply data-rid={rid} data-mid={mid} onClick={openThread}>{t('Reply')}</Reply>
<Metrics>
<Metrics.Item title={t('Replies')}>
Expand Down
9 changes: 9 additions & 0 deletions client/components/Message/hooks/useBlockRendered.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { useRef, useEffect } from 'react';

export const useBlockRendered = () => {
const ref = useRef();
useEffect(() => {
ref.current.dispatchEvent(new Event('rendered'));
}, []);
return { className: 'js-block-wrapper', ref };
};