summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/views/stream/hootstream.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/js/lib/views/stream/hootstream.js')
-rw-r--r--public/assets/js/lib/views/stream/hootstream.js35
1 files changed, 31 insertions, 4 deletions
diff --git a/public/assets/js/lib/views/stream/hootstream.js b/public/assets/js/lib/views/stream/hootstream.js
index 777489d..628d59c 100644
--- a/public/assets/js/lib/views/stream/hootstream.js
+++ b/public/assets/js/lib/views/stream/hootstream.js
@@ -109,7 +109,12 @@ var HootStream = View.extend({
) {
return true;
}
- if (filters.images && thread.images.length) {
+ if (
+ (filters.images && thread.images.length) ||
+ thread.comments.some((comment) =>
+ CONTAINS_IMAGE_URL_REGEXP.test(comment.comment)
+ )
+ ) {
return true;
}
return false;
@@ -131,10 +136,20 @@ var HootStream = View.extend({
return filters.files;
})
: [],
- comments: filters.hoots ? thread.comments : [],
+ comments: filters.hoots
+ ? thread.comments
+ : filters.images
+ ? thread.comments.filter((comment) =>
+ CONTAINS_IMAGE_URL_REGEXP.test(comment.comment)
+ )
+ : [],
query: data.query,
};
- if (threadData.files.length || threadData.comments.length) {
+ if (
+ threadData.images.length ||
+ threadData.files.length ||
+ threadData.comments.length
+ ) {
return this.renderThread(threadData).reduce(
($el, $item) => $el.append($item),
$("<div class='thread'>")
@@ -238,6 +253,16 @@ var HootStream = View.extend({
1.0
);
+ const filteredImages = images
+ .map((image) => [image, new RegExp(encodeURIComponent(image.filename))])
+ .filter(
+ ([, filenameRegexp]) =>
+ !comments.some((comment) => filenameRegexp.test(comment.comment))
+ )
+ .map(([image]) => image);
+
+ console.log(filteredImages);
+
// console.log(thread);
return [
"<div class='divider dark'></div>",
@@ -257,7 +282,9 @@ var HootStream = View.extend({
comment_opacity: age_opacity * get_size_opacity(thread.comment_count),
}),
this.renderImages(
- isViewingThread || postedToday ? images : images.slice(0, 6)
+ isViewingThread || postedToday
+ ? filteredImages
+ : filteredImages.slice(0, 6)
),
this.renderFiles(
isViewingThread || postedToday ? files : files.slice(0, 10)