don't put body parts in span
This commit is contained in:
parent
629d58b041
commit
9aedc1d526
1 changed files with 13 additions and 16 deletions
|
@ -14,21 +14,28 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {StaticView} from "../../../general/StaticView.js";
|
|
||||||
import {tag, text, classNames} from "../../../general/html.js";
|
import {tag, text, classNames} from "../../../general/html.js";
|
||||||
import {BaseMessageView} from "./BaseMessageView.js";
|
import {BaseMessageView} from "./BaseMessageView.js";
|
||||||
|
|
||||||
export class TextMessageView extends BaseMessageView {
|
export class TextMessageView extends BaseMessageView {
|
||||||
renderMessageBody(t, vm) {
|
renderMessageBody(t, vm) {
|
||||||
return t.p({
|
const time = t.time({className: {hidden: !vm.date}}, vm.date + " " + vm.time);
|
||||||
|
const container = t.div({
|
||||||
className: {
|
className: {
|
||||||
"Timeline_messageBody": true,
|
"Timeline_messageBody": true,
|
||||||
statusMessage: vm => vm.shape === "message-status",
|
statusMessage: vm => vm.shape === "message-status",
|
||||||
},
|
},
|
||||||
}, [
|
});
|
||||||
t.mapView(vm => vm.body, body => new BodyView(body)),
|
t.mapSideEffect(vm => vm.body, body => {
|
||||||
t.time({className: {hidden: !vm.date}}, vm.date + " " + vm.time)
|
while (container.lastChild) {
|
||||||
]);
|
container.removeChild(container.lastChild);
|
||||||
|
}
|
||||||
|
for (const part of body.parts) {
|
||||||
|
container.appendChild(renderPart(part));
|
||||||
|
}
|
||||||
|
container.appendChild(time);
|
||||||
|
});
|
||||||
|
return container;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,13 +112,3 @@ function renderPart(part) {
|
||||||
function renderParts(parts) {
|
function renderParts(parts) {
|
||||||
return Array.from(parts, renderPart);
|
return Array.from(parts, renderPart);
|
||||||
}
|
}
|
||||||
|
|
||||||
class BodyView extends StaticView {
|
|
||||||
render(t, messageBody) {
|
|
||||||
const container = t.span();
|
|
||||||
for (const part of messageBody.parts) {
|
|
||||||
container.appendChild(renderPart(part));
|
|
||||||
}
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Reference in a new issue