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
assets
client/src/js/util

File diff suppressed because one or more lines are too long

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