From ae29144f18bbd0cac3c65ae4bf869fade1c5ffb0 Mon Sep 17 00:00:00 2001 From: julian laplace Date: Thu, 27 Oct 2022 00:06:16 +0200 Subject: fixing things :) --- public/assets/css/hootstream.css | 2 +- public/assets/js/lib/views/stream/hootfilters.js | 14 +++++++++++++- public/assets/js/lib/views/stream/hootstream.js | 7 ++++--- public/assets/js/lib/views/stream/index.js | 4 +++- 4 files changed, 21 insertions(+), 6 deletions(-) (limited to 'public') diff --git a/public/assets/css/hootstream.css b/public/assets/css/hootstream.css index bcd73f1..a9fc5fd 100644 --- a/public/assets/css/hootstream.css +++ b/public/assets/css/hootstream.css @@ -422,7 +422,7 @@ padding-right: 0; } #hootfilters .links { - margin: 0.75rem 0.75rem 0 0.75rem; + margin: 0rem 0.75rem 0 0.75rem; } #hootevents .userLink { display: none; 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); }, -- cgit v1.2.3-70-g09d2