summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/views/stream
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/js/lib/views/stream')
-rw-r--r--public/assets/js/lib/views/stream/hootfilters.js14
-rw-r--r--public/assets/js/lib/views/stream/hootstream.js7
-rw-r--r--public/assets/js/lib/views/stream/index.js4
3 files changed, 20 insertions, 5 deletions
diff --git a/public/assets/js/lib/views/stream/hootfilters.js b/public/assets/js/lib/views/stream/hootfilters.js
index 7aed3f4..cfcbdf0 100644
--- a/public/assets/js/lib/views/stream/hootfilters.js
+++ b/public/assets/js/lib/views/stream/hootfilters.js
@@ -50,7 +50,19 @@ var HootFilters = View.extend({
);
},
- load: function () {},
+ load: function ({ threads, comments, files, hootbox, lastlog }) {
+ const hoots = !!(hootbox?.length || lastlog?.length || comments?.length);
+ const music = !!files.some((file) => AUDIO_REGEXP.test(file.filename));
+ const images = !!files.some((file) => IMAGE_REGEXP.test(file.filename));
+ const normal_files = !!files.some(
+ (file) =>
+ !AUDIO_REGEXP.test(file.filename) && !IMAGE_REGEXP.test(file.filename)
+ );
+ this.$images.closest("label").toggle(images);
+ this.$music.closest("label").toggle(music);
+ this.$hoots.closest("label").toggle(hoots);
+ this.$files.closest("label").toggle(normal_files);
+ },
filter: function (event) {
const { name, checked } = event.target;
diff --git a/public/assets/js/lib/views/stream/hootstream.js b/public/assets/js/lib/views/stream/hootstream.js
index c93b5db..2789dee 100644
--- a/public/assets/js/lib/views/stream/hootstream.js
+++ b/public/assets/js/lib/views/stream/hootstream.js
@@ -86,10 +86,11 @@ var HootStream = View.extend({
}
// console.log(sortedOrder, threadLookup);
+ // Filter the elements that we're going to display
const $els = sortedOrder
.filter(({ type, thread_id }) => {
- if (filters.hoots && (type === "hoot" || type === "lastlog")) {
- return true;
+ if (type === "hoot" || type === "lastlog") {
+ return filters.hoots;
}
const thread = threadLookup[thread_id];
if (filters.hoots && thread.comments && thread.comments.length) {
@@ -97,7 +98,6 @@ var HootStream = View.extend({
}
if (
filters.music &&
- thread.files &&
thread.files.some((file) => AUDIO_REGEXP.test(file.filename))
) {
return true;
@@ -115,6 +115,7 @@ var HootStream = View.extend({
function ({ type, thread_id, data: itemData }) {
// console.log(type, thread_id);
if (type === "thread") {
+ // Filter thread contents
const thread = threadLookup[thread_id];
const threadData = {
...thread,
diff --git a/public/assets/js/lib/views/stream/index.js b/public/assets/js/lib/views/stream/index.js
index 8ef9208..e961fc2 100644
--- a/public/assets/js/lib/views/stream/index.js
+++ b/public/assets/js/lib/views/stream/index.js
@@ -10,13 +10,14 @@ var StreamView = View.extend({
load: function ({ ...target }) {
$("body").addClass("index");
- console.log(target);
+ console.log("target", target);
$.get(this.action, target, this.populate.bind(this));
},
populate: function (data) {
$("body").removeClass("loading");
this.data = data;
+ this.hootfilters.load(data);
this.hootstream.load(data, this.hootfilters.state);
if (data.mail.count) {
$(".alert")
@@ -43,6 +44,7 @@ var StreamView = View.extend({
},
onFilter: function (filters) {
+ console.log("onfilter");
this.hootstream.build(filters);
},