Custom Emoji: Fix editing message, resize (#2138)
This commit is contained in:
parent
d6389c010f
commit
0ae64c0c54
@ -63,6 +63,7 @@ import {
|
|||||||
} from '../helpers';
|
} from '../helpers';
|
||||||
import { interpolateArray } from '../../../util/waveform';
|
import { interpolateArray } from '../../../util/waveform';
|
||||||
import { requestChatUpdate } from './chats';
|
import { requestChatUpdate } from './chats';
|
||||||
|
import parseEmojiOnlyString from '../../../util/parseEmojiOnlyString';
|
||||||
|
|
||||||
const FAST_SEND_TIMEOUT = 1000;
|
const FAST_SEND_TIMEOUT = 1000;
|
||||||
const INPUT_WAVEFORM_LENGTH = 63;
|
const INPUT_WAVEFORM_LENGTH = 63;
|
||||||
@ -486,6 +487,7 @@ export async function editMessage({
|
|||||||
serverTimeOffset: number;
|
serverTimeOffset: number;
|
||||||
}) {
|
}) {
|
||||||
const isScheduled = message.date * 1000 > Date.now() + serverTimeOffset * 1000;
|
const isScheduled = message.date * 1000 > Date.now() + serverTimeOffset * 1000;
|
||||||
|
const emojiOnlyCount = text ? parseEmojiOnlyString(text) : undefined;
|
||||||
const messageUpdate: Partial<ApiMessage> = {
|
const messageUpdate: Partial<ApiMessage> = {
|
||||||
content: {
|
content: {
|
||||||
...message.content,
|
...message.content,
|
||||||
@ -496,6 +498,7 @@ export async function editMessage({
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
emojiOnlyCount: emojiOnlyCount || undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
onUpdate({
|
onUpdate({
|
||||||
|
|||||||
@ -35,8 +35,10 @@ export function buildCustomEmojiHtmlFromEntity(rawText: string, entity: ApiMessa
|
|||||||
/>`;
|
/>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCustomEmojiSize(maxEmojisInLine: number): number | undefined {
|
export function getCustomEmojiSize(maxEmojisInLine?: number): number | undefined {
|
||||||
if (maxEmojisInLine > EMOJI_SIZES) return undefined;
|
if (!maxEmojisInLine) return undefined;
|
||||||
|
|
||||||
return (6 - (maxEmojisInLine * 0.625)) * REM; // Should be the same as in _message-content.scss
|
// Should be the same as in _message-content.scss
|
||||||
|
if (maxEmojisInLine > EMOJI_SIZES) return REM * 2.25;
|
||||||
|
return (6 - (maxEmojisInLine * 0.5)) * REM;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -523,7 +523,7 @@ const Message: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
const withAppendix = contentClassName.includes('has-appendix');
|
const withAppendix = contentClassName.includes('has-appendix');
|
||||||
const hasText = hasMessageText(message);
|
const hasText = hasMessageText(message);
|
||||||
const emojiSize = message.emojiOnlyCount && getCustomEmojiSize(message.emojiOnlyCount);
|
const emojiSize = getCustomEmojiSize(message.emojiOnlyCount);
|
||||||
|
|
||||||
let metaPosition!: MetaPosition;
|
let metaPosition!: MetaPosition;
|
||||||
if (phoneCall) {
|
if (phoneCall) {
|
||||||
|
|||||||
@ -706,7 +706,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.emoji-only {
|
&.emoji-only {
|
||||||
--emoji-only-size: 1.25rem;
|
--emoji-only-size: 2.25rem;
|
||||||
font-size: var(--emoji-only-size);
|
font-size: var(--emoji-only-size);
|
||||||
min-width: 6rem;
|
min-width: 6rem;
|
||||||
|
|
||||||
@ -738,7 +738,7 @@
|
|||||||
|
|
||||||
@for $i from 1 through 7 {
|
@for $i from 1 through 7 {
|
||||||
&.emoji-only-#{$i} {
|
&.emoji-only-#{$i} {
|
||||||
$size: 6 - ($i * 0.625) + rem;
|
$size: 6 - ($i * 0.5) + rem;
|
||||||
|
|
||||||
--emoji-only-size: #{$size};
|
--emoji-only-size: #{$size};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,9 +29,17 @@ const parseEmojiOnlyString = (text: string): number | false => {
|
|||||||
return emojiCount;
|
return emojiCount;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (countPerLine.some((count) => count === -1)) return false;
|
let max = lines.length;
|
||||||
|
for (let i = 0; i < countPerLine.length; i++) {
|
||||||
|
if (countPerLine[i] === -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (countPerLine[i] > max) {
|
||||||
|
max = countPerLine[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Math.max(...countPerLine);
|
return max;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default parseEmojiOnlyString;
|
export default parseEmojiOnlyString;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user