summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/views/stream
diff options
context:
space:
mode:
authorjulian laplace <julescarbon@gmail.com>2022-10-27 16:42:57 +0200
committerjulian laplace <julescarbon@gmail.com>2022-10-27 16:42:57 +0200
commit83c938702eb67bd6d154bb98b632e64e5e7e183f (patch)
tree7b2b64a91f68cbcd4d4b2089b3a24b3f40bde88f /public/assets/js/lib/views/stream
parent53644b55eb3a6a355f25e4a30b62c2c78451cd29 (diff)
add player and image viewer
Diffstat (limited to 'public/assets/js/lib/views/stream')
-rw-r--r--public/assets/js/lib/views/stream/hootstream.js79
1 files changed, 37 insertions, 42 deletions
diff --git a/public/assets/js/lib/views/stream/hootstream.js b/public/assets/js/lib/views/stream/hootstream.js
index 6c02cc6..777489d 100644
--- a/public/assets/js/lib/views/stream/hootstream.js
+++ b/public/assets/js/lib/views/stream/hootstream.js
@@ -104,12 +104,14 @@ var HootStream = View.extend({
return true;
}
if (
- filters.images &&
- thread.files &&
- thread.files.some((file) => IMAGE_REGEXP.test(file.filename))
+ filters.files &&
+ thread.files.some((file) => !AUDIO_REGEXP.test(file.filename))
) {
return true;
}
+ if (filters.images && thread.images.length) {
+ return true;
+ }
return false;
})
.map(
@@ -120,18 +122,15 @@ var HootStream = View.extend({
const thread = threadLookup[thread_id];
const threadData = {
...thread,
- files:
- filters.images || filters.music
- ? thread.files.filter((file) => {
- if (AUDIO_REGEXP.test(file.filename)) {
- return filters.music;
- }
- if (IMAGE_REGEXP.test(file.filename)) {
- return filters.images;
- }
- return filters.files;
- })
- : [],
+ images: filters.images ? thread.images : [],
+ files: filters.music
+ ? thread.files.filter((file) => {
+ if (AUDIO_REGEXP.test(file.filename)) {
+ return filters.music;
+ }
+ return filters.files;
+ })
+ : [],
comments: filters.hoots ? thread.comments : [],
query: data.query,
};
@@ -257,38 +256,34 @@ var HootStream = View.extend({
comment_count: `${thread.comment_count || 0} c.`,
comment_opacity: age_opacity * get_size_opacity(thread.comment_count),
}),
- // this.renderImages(
- // isViewingThread || postedToday ? images : images.slice(0, 6)
- // ),
+ this.renderImages(
+ isViewingThread || postedToday ? images : images.slice(0, 6)
+ ),
this.renderFiles(
isViewingThread || postedToday ? files : files.slice(0, 10)
),
...this.renderHoots({
- hoots: comments
- .slice(0, 1)
- .map(
- trimComment({
- isViewingThread,
- lines: 5,
- snippetSize: 512,
- cropSize: 256,
- })
- ),
+ hoots: comments.slice(0, 1).map(
+ trimComment({
+ isViewingThread,
+ lines: 5,
+ snippetSize: 512,
+ cropSize: 256,
+ })
+ ),
className: "first_post",
}),
...this.renderHoots({
hoots:
isViewingThread || postedToday
- ? comments
- .slice(1)
- .map(
- trimComment({
- isViewingThread,
- lines: 1,
- snippetSize: 256,
- cropSize: 128,
- })
- )
+ ? comments.slice(1).map(
+ trimComment({
+ isViewingThread,
+ lines: 1,
+ snippetSize: 256,
+ cropSize: 128,
+ })
+ )
: comments
.slice(1)
.slice(-5)
@@ -305,13 +300,13 @@ var HootStream = View.extend({
];
},
- renderImages: function (files) {
- if (!files.length) {
+ renderImages: function (images) {
+ if (!images.length) {
return null;
}
const $table = $("<div class='imageList'>");
- for (const file of files) {
- const $el = this.renderFile(this.imageTemplate, file);
+ for (const image of images) {
+ const $el = this.renderFile(this.imageTemplate, image);
$table.append($el);
}
return $table;