- commit
- 8d19b39eb7c92dd7a51b17e3ada233e5d23dd403
- parent
- c952f590df1d3710b42ae0d5115554581f009cef
- author
- Dami <dami.etoile@gmail.com>
| M | internal/ | 8 | ++++---- |
| M | internal/ | 4 | ++-- |
| M | internal/ | 4 | ++-- |
@@ -636,16 +636,16 @@
636636 if (footer.childNodes.length) node.append(footer);637637 return node;638638 };639- const roomBox = () => document.getElementById("content");639+ // The timeline scrolls inside the content column on desktop and with the640+ // page body on phones; roomBox finds whichever holds the overflow.641+ const roomBox = () => [document.getElementById("content"), document.body, document.documentElement].find(node => node && node.scrollHeight > node.clientHeight + 1 && /auto|scroll/.test(getComputedStyle(node).overflowY)) || null;640642 const roomNearBottom = () => {641643 const box = roomBox();642- if (box && box.scrollHeight > box.clientHeight + 1 && getComputedStyle(box).overflowY !== "visible") return box.scrollHeight - box.scrollTop - box.clientHeight < 120;643- return document.documentElement.scrollHeight - window.scrollY - window.innerHeight < 120;644+ return !box || box.scrollHeight - box.scrollTop - box.clientHeight < 120;644645 };645646 const roomScroll = () => {646647 const box = roomBox();647648 if (box) box.scrollTop = box.scrollHeight;648- window.scrollTo(0, document.documentElement.scrollHeight);649649 };650650 // roomAppend adds one message to the timeline unless it is already there,651651 // keeps the list bounded and follows the newest message when the viewer@@ -43,7 +43,7 @@
4343 </section>4444 {{else}}{{$data := asMap .Event}}{{$room := asMap (index $data "room")}}{{$id := str (index $room "id")}}{{$root := roomRoot .Event}}<section id="thread">4545 <p id="crumbs"><a href="/rooms/{{$id}}">{{or (str (index $room "name")) $id}}</a></p>46-<h1>Thread <small>{{$root.Replies}} replies</small></h1>46+<h1>Thread <small>{{$root.Replies}} {{if eq $root.Replies 1}}reply{{else}}replies{{end}}</small></h1>4747 <div id="root">{{template "roomMessage" $root}}</div>4848 <div id="messages">{{range roomItems .Event "replies"}}4949 {{template "roomMessage" .}}{{else}}<p id="empty">No replies yet.</p>{{end}}@@ -60,5 +60,5 @@
6060 {{define "roomMessage"}}<room-message id="msg-{{.ID}}" data-id="{{.ID}}" data-kind="{{.Kind}}" data-pubkey="{{.PubKey}}"{{if .Agent}} data-agent{{end}}{{if .Notice}} data-notice{{end}}>6161 <header><b>{{template "nostrKey" .PubKey}}</b>{{if .Role}} | {{.Role}}{{end}}<small><time datetime="{{datetime .CreatedAt}}" title="{{when .CreatedAt}}">{{clock .CreatedAt}}</time></small></header>6262 <p>{{if .Notice}}{{.Notice}}{{else}}{{roomContent .Content}}{{end}}</p>63-{{if or .Mentions (and (not .InThread) (or (eq .Kind "11") .Root)) .Reactions}}<footer>{{if .Mentions}}<span>to {{range .Mentions}}{{template "nostrKey" .}} {{end}}</span>{{end}}{{if not .InThread}}{{if eq .Kind "11"}}<a href="/rooms/{{.Room}}/thread/{{.ID}}">thread{{if .Replies}} | {{.Replies}} replies{{end}}</a>{{else if .Root}}<a href="/rooms/{{.Room}}/thread/{{.Root}}">in thread</a>{{end}}{{end}}{{range .Reactions}}<span data-reaction="{{.Content}}">{{.Content}} {{.Count}}</span>{{end}}</footer>{{end}}63+{{if or .Mentions (and (not .InThread) (or (eq .Kind "11") .Root)) .Reactions}}<footer>{{if .Mentions}}<span>to {{range .Mentions}}{{template "nostrKey" .}} {{end}}</span>{{end}}{{if not .InThread}}{{if eq .Kind "11"}}<a href="/rooms/{{.Room}}/thread/{{.ID}}">thread{{if .Replies}} | {{.Replies}} {{if eq .Replies 1}}reply{{else}}replies{{end}}{{end}}</a>{{else if .Root}}<a href="/rooms/{{.Room}}/thread/{{.Root}}">in thread</a>{{end}}{{end}}{{range .Reactions}}<span data-reaction="{{.Content}}">{{.Content}} {{.Count}}</span>{{end}}</footer>{{end}}6464 </room-message>{{end}}@@ -146,7 +146,7 @@ func TestRoomPageRendersMessagesOldestFirstWithMarkers(t *testing.T) {
146146 `<script>alert(1)</script>`,147147 `<span>to <nostr-key hex="` + roomAgent + `"`,148148 `<span data-reaction="+1">+1 1</span>`,149- `<a href="/rooms/general/thread/` + roomThread + `">thread | 1 replies</a>`,149+ `<a href="/rooms/general/thread/` + roomThread + `">thread | 1 reply</a>`,150150 `<a href="/rooms/general/thread/` + roomThread + `">in thread</a>`,151151 `<room-live room="general"></room-live>`,152152 `<room-compose room="general" pubkey="` + roomOwner + `">`,@@ -197,7 +197,7 @@ func TestThreadPageRendersRootRepliesAndReplyCompose(t *testing.T) {
197197 app, _ := roomsApp(t, roomOwner)198198 body := roomsPage(t, app, "/rooms/general/thread/"+roomThread)199199 for _, want := range []string{200- `<p id="crumbs"><a href="/rooms/general">General</a></p>`, `<h1>Thread <small>1 replies</small></h1>`,200+ `<p id="crumbs"><a href="/rooms/general">General</a></p>`, `<h1>Thread <small>1 reply</small></h1>`,201201 `<div id="root"><room-message id="msg-` + roomThread + `"`, `<div id="messages">`, `id="msg-` + roomReply + `"`,202202 `<room-live room="general" root="` + roomThread + `"></room-live>`,203203 `<room-compose room="general" pubkey="` + roomOwner + `" kind="12" root="` + roomThread + `" root-pubkey="` + roomAgent + `">`,