Fix wrapWidth for channels on small screens

This commit is contained in:
Ken-Håvard Lieng 2017-03-29 23:45:09 +02:00
parent bb8a4d180e
commit e19280c2c7
2 changed files with 29 additions and 20 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,21 @@
const lineHeight = 24;
let prevWidth;
let windowWidth;
export default function messageHeight(message, width, charWidth, indent = 0) {
let pad = (6 + (message.from ? message.from.length + 1 : 0)) * charWidth;
let height = lineHeight + 4;
if (message.channel) {
if (width !== prevWidth) {
prevWidth = width;
windowWidth = window.innerWidth;
}
if (windowWidth > 600) {
width -= 200;
}
}
if (pad + (message.message.length * charWidth) < width) {
return height;