Skip to content

Commit

Permalink
Merge pull request #498 from vector-im/bwindels/fix-replies
Browse files Browse the repository at this point in the history
Fix replies after releasing scroll improvements
  • Loading branch information
bwindels authored Sep 16, 2021
2 parents ccc5aac + 41089e2 commit 5cf8c3c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/domain/session/room/ComposerViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class ComposerViewModel extends ViewModel {
}

setReplyingTo(entry) {
const changed = this._replyVM?.id?.equals(entry?.asEventKey());
const changed = new Boolean(entry) !== new Boolean(this._replyVM) || !this._replyVM?.id.equals(entry.asEventKey());
if (changed) {
this._replyVM = this.disposeTracked(this._replyVM);
if (entry) {
Expand Down
1 change: 0 additions & 1 deletion src/platform/web/ui/session/room/TimelineView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ export class TimelineView extends TemplateView<TimelineViewModel> {
bottomNodeIndex = len - 1;
} else {
const viewportBottom = scrollTop + clientHeight;
// console.log(`viewportBottom: ${viewportBottom} (${scrollTop} + ${clientHeight})`);
const anchoredNodeIndex = findFirstNodeIndexAtOrBelow(tilesNode, viewportBottom);
this.anchoredNode = tilesNode.childNodes[anchoredNodeIndex] as HTMLElement;
this.anchoredBottom = bottom(this.anchoredNode!);
Expand Down
16 changes: 8 additions & 8 deletions src/platform/web/ui/session/room/timeline/BaseMessageView.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,18 @@ export class BaseMessageView extends TemplateView {
}

render(t, vm) {
const children = [this.renderMessageBody(t, vm)];
if (this._interactive) {
children.push(t.button({className: "Timeline_messageOptions"}, "⋯"));
}
const li = t.el(this._tagName, {className: {
"Timeline_message": true,
own: vm.isOwn,
unsent: vm.isUnsent,
unverified: vm.isUnverified,
disabled: !this._interactive,
continuation: vm => vm.isContinuation,
}}, [
// dynamically added and removed nodes are handled below
this.renderMessageBody(t, vm),
// should be after body as it is overlayed on top
this._interactive ? t.button({className: "Timeline_messageOptions"}, "⋯") : [],
]);
const avatar = t.a({href: vm.memberPanelLink, className: "Timeline_messageAvatar"}, [renderStaticAvatar(vm, 30)]);
}}, children);
// given that there can be many tiles, we don't add
// unneeded DOM nodes in case of a continuation, and we add it
// with a side-effect binding to not have to create sub views,
Expand All @@ -57,8 +55,10 @@ export class BaseMessageView extends TemplateView {
li.removeChild(li.querySelector(".Timeline_messageAvatar"));
li.removeChild(li.querySelector(".Timeline_messageSender"));
} else if (!isContinuation) {
const avatar = tag.a({href: vm.memberPanelLink, className: "Timeline_messageAvatar"}, [renderStaticAvatar(vm, 30)]);
const sender = tag.div({className: `Timeline_messageSender usercolor${vm.avatarColorNumber}`}, vm.displayName);
li.insertBefore(avatar, li.firstChild);
li.insertBefore(tag.div({className: `Timeline_messageSender usercolor${vm.avatarColorNumber}`}, vm.displayName), li.firstChild);
li.insertBefore(sender, li.firstChild);
}
});
// similarly, we could do this with a simple ifView,
Expand Down

0 comments on commit 5cf8c3c

Please sign in to comment.