diff options
| author | julian laplace <julescarbon@gmail.com> | 2022-10-26 19:29:14 +0200 |
|---|---|---|
| committer | julian laplace <julescarbon@gmail.com> | 2022-10-26 19:29:14 +0200 |
| commit | 1e2830de34e03371f7deafb40b2542b75ce2ed4b (patch) | |
| tree | 63ca92863b3fbff7a34a99b9263226a7b46a0ad2 /public/assets/js/lib/views/stream | |
| parent | 5a697b0a4fb2578a98a1b8e064ebe62dad9616e2 (diff) | |
trim posts
Diffstat (limited to 'public/assets/js/lib/views/stream')
| -rw-r--r-- | public/assets/js/lib/views/stream/hootstream.js | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/public/assets/js/lib/views/stream/hootstream.js b/public/assets/js/lib/views/stream/hootstream.js index ed6de22..2de184a 100644 --- a/public/assets/js/lib/views/stream/hootstream.js +++ b/public/assets/js/lib/views/stream/hootstream.js @@ -27,6 +27,7 @@ var HootStream = View.extend({ case "userLink": case "threadLink": case "keywordLink": + case "readMore": event.preventDefault(); console.log(">>", url.pathname); app.router.pushState(url.pathname); @@ -44,7 +45,10 @@ var HootStream = View.extend({ function (item) { // console.log(item.type, item.thread_id); return item.type === "thread" - ? this.renderThread(threadLookup[item.thread_id]).reduce( + ? this.renderThread({ + ...threadLookup[item.thread_id], + query: data.query, + }).reduce( ($el, $item) => $el.append($item), $("<div class='thread'>") ) @@ -119,13 +123,14 @@ var HootStream = View.extend({ return els; }, - renderThread: function ({ thread, comments, files, images }) { + renderThread: function ({ query, thread, comments, files, images }) { if (!thread || !thread.length) { console.error("Missing thread"); console.error(thread, comments, files, images); return ["<div>Missing thread!</div>"]; } thread = thread.shift(); + const isViewingThread = query.thread === thread.id; // console.log(thread, comments, files, images); const postedToday = +new Date() / 1000 - thread.lastmodified < 86400; const age_opacity = get_age_opacity(thread.lastmodified); @@ -146,7 +151,10 @@ var HootStream = View.extend({ comment_opacity: age_opacity * get_size_opacity(comments.length), }), this.renderFiles(postedToday ? files : files.slice(0, 10)), - ...this.renderHoots({ hoots: comments.slice(0, 1), tag: "first_post" }), + ...this.renderHoots({ + hoots: comments.slice(0, 1).map(trimComment(isViewingThread)), + tag: "first_post", + }), ...this.renderHoots({ hoots: postedToday ? comments.slice(1) : comments.slice(1).slice(-5), }), |
