remove body pending loading of message > 2000.

Also remove the limit when sending text messages
This commit is contained in:
Audric Ackermann 2021-01-27 11:57:38 +11:00
parent 0fe026ab15
commit 7054385d4a
No known key found for this signature in database
GPG key ID: 999F434D76324AD4
4 changed files with 17 additions and 54 deletions

View file

@ -82,9 +82,7 @@ export class MessageBody extends React.Component<Props> {
isGroup: false, isGroup: false,
}; };
public addDownloading(jsx: JSX.Element): JSX.Element { public renderJsxSelectable(jsx: JSX.Element): JSX.Element {
const { i18n } = this.props;
return <span className="text-selectable">{jsx}</span>; return <span className="text-selectable">{jsx}</span>;
} }
@ -100,7 +98,7 @@ export class MessageBody extends React.Component<Props> {
const sizeClass = disableJumbomoji ? undefined : getSizeClass(text); const sizeClass = disableJumbomoji ? undefined : getSizeClass(text);
if (disableLinks) { if (disableLinks) {
return this.addDownloading( return this.renderJsxSelectable(
renderEmoji({ renderEmoji({
i18n, i18n,
text, text,
@ -113,24 +111,7 @@ export class MessageBody extends React.Component<Props> {
); );
} }
const bodyContents = this.addDownloading( return this.renderJsxSelectable(
<Linkify
text={text}
renderNonLink={({ key, text: nonLinkText }) => {
return renderEmoji({
i18n,
text: nonLinkText,
sizeClass,
key,
renderNonEmoji: renderNewLines,
isGroup,
convoId,
});
}}
/>
);
return this.addDownloading(
<Linkify <Linkify
text={text} text={text}
renderNonLink={({ key, text: nonLinkText }) => { renderNonLink={({ key, text: nonLinkText }) => {

View file

@ -96,14 +96,14 @@ export const MessageMetadata = (props: Props) => {
theme={theme} theme={theme}
/> />
) : ( ) : (
<Timestamp <Timestamp
timestamp={serverTimestamp || timestamp} timestamp={serverTimestamp || timestamp}
extended={true} extended={true}
withImageNoCaption={withImageNoCaption} withImageNoCaption={withImageNoCaption}
isConversationListItem={false} isConversationListItem={false}
theme={theme} theme={theme}
/> />
)} )}
<MetadataBadges <MetadataBadges
direction={direction} direction={direction}
isPublic={isPublic} isPublic={isPublic}
@ -122,7 +122,6 @@ export const MessageMetadata = (props: Props) => {
/> />
) : null} ) : null}
<MetadataSpacer /> <MetadataSpacer />
<MetadataSpacer />
{showStatus ? ( {showStatus ? (
<OutgoingMessageStatus <OutgoingMessageStatus
iconColor={messageStatusColor} iconColor={messageStatusColor}

View file

@ -374,7 +374,7 @@ export class SessionCompositionBox extends React.Component<Props, State> {
spellCheck={true} spellCheck={true}
inputRef={this.textarea} inputRef={this.textarea}
disabled={!typingEnabled} disabled={!typingEnabled}
maxLength={Constants.CONVERSATION.MAX_MESSAGE_BODY_LENGTH} // maxLength={Constants.CONVERSATION.MAX_MESSAGE_BODY_LENGTH}
rows={1} rows={1}
style={sendMessageStyle} style={sendMessageStyle}
suggestionsPortalHost={this.container} suggestionsPortalHost={this.container}
@ -751,25 +751,8 @@ export class SessionCompositionBox extends React.Component<Props, State> {
// tslint:disable-next-line: cyclomatic-complexity // tslint:disable-next-line: cyclomatic-complexity
private async onSendMessage() { private async onSendMessage() {
const toUnicode = (str: string) => {
return str
.split('')
.map(value => {
const temp = value
.charCodeAt(0)
.toString(16)
.toUpperCase();
if (temp.length > 2) {
return `\\u${temp}`;
}
return value;
})
.join('');
};
// this is dirty but we have to replace all @(xxx) by @xxx manually here // this is dirty but we have to replace all @(xxx) by @xxx manually here
const cleanMentions = (text: string): string => { const cleanMentions = (text: string): string => {
const textUnicode = toUnicode(text);
const matches = text.match(this.mentionsRegex); const matches = text.match(this.mentionsRegex);
let replacedMentions = text; let replacedMentions = text;
(matches || []).forEach(match => { (matches || []).forEach(match => {
@ -808,10 +791,10 @@ export class SessionCompositionBox extends React.Component<Props, State> {
} }
// Verify message length // Verify message length
const msgLen = messagePlaintext?.length || 0; const msgLen = messagePlaintext?.length || 0;
if (msgLen > Constants.CONVERSATION.MAX_MESSAGE_BODY_LENGTH) { // if (msgLen > Constants.CONVERSATION.MAX_MESSAGE_BODY_LENGTH) {
ToastUtils.pushMessageBodyTooLong(); // ToastUtils.pushMessageBodyTooLong();
return; // return;
} // }
if (msgLen === 0 && this.props.stagedAttachments?.length === 0) { if (msgLen === 0 && this.props.stagedAttachments?.length === 0) {
ToastUtils.pushMessageBodyMissing(); ToastUtils.pushMessageBodyMissing();
return; return;

View file

@ -9,7 +9,7 @@ export const TTL_DEFAULT = {
// User Interface // User Interface
export const CONVERSATION = { export const CONVERSATION = {
MAX_MESSAGE_BODY_LENGTH: 2000, // MAX_MESSAGE_BODY_LENGTH: 2000,
DEFAULT_MEDIA_FETCH_COUNT: 50, DEFAULT_MEDIA_FETCH_COUNT: 50,
DEFAULT_DOCUMENTS_FETCH_COUNT: 150, DEFAULT_DOCUMENTS_FETCH_COUNT: 150,
DEFAULT_MESSAGE_FETCH_COUNT: 30, DEFAULT_MESSAGE_FETCH_COUNT: 30,