logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git
commit: def68e9cda881447bb2d278248635d7ff4f2498f
parent 23edfe7b918844f8cc2ff5b9b245952092ee1cbf
Author: Henry Jameson <me@hjkos.com>
Date:   Mon, 25 Mar 2024 23:34:19 +0200

scrobbles age setting

Diffstat:

Msrc/components/settings_modal/tabs/filtering_tab.js2++
Msrc/components/settings_modal/tabs/filtering_tab.vue10++++++++++
Msrc/components/status/status.js20+++++++++++++++++++-
Msrc/i18n/en.json1+
Msrc/modules/config.js1+
5 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/src/components/settings_modal/tabs/filtering_tab.js b/src/components/settings_modal/tabs/filtering_tab.js @@ -1,6 +1,7 @@ import { filter, trim, debounce } from 'lodash' import BooleanSetting from '../helpers/boolean_setting.vue' import ChoiceSetting from '../helpers/choice_setting.vue' +import SizeSetting from '../helpers/size_setting.vue' import IntegerSetting from '../helpers/integer_setting.vue' import SharedComputedObject from '../helpers/shared_computed_object.js' @@ -19,6 +20,7 @@ const FilteringTab = { components: { BooleanSetting, ChoiceSetting, + SizeSetting, IntegerSetting }, computed: { diff --git a/src/components/settings_modal/tabs/filtering_tab.vue b/src/components/settings_modal/tabs/filtering_tab.vue @@ -96,6 +96,16 @@ {{ $t('settings.hide_scrobbles') }} </BooleanSetting> </li> + <li> + <SizeSetting + key="hideScrobblesAfter" + path="hideScrobblesAfter" + :units="['m', 'h', 'd']" + expert="1" + > + {{ $t('settings.hide_scrobbles_after') }} + </SizeSetting> + </li> </ul> </div> <div diff --git a/src/components/status/status.js b/src/components/status/status.js @@ -414,7 +414,25 @@ const Status = { return this.quotedStatus && this.displayQuote }, scrobblePresent () { - return !this.mergedConfig.hideScrobbles && this.status.user.latestScrobble && this.status.user.latestScrobble.artist + if (this.mergedConfig.hideScrobbles) return false + if (!this.status.user.latestScrobble) return false + const value = this.mergedConfig.hideScrobblesAfter.match(/\d+/gs)[0] + const unit = this.mergedConfig.hideScrobblesAfter.match(/\D+/gs)[0] + let multiplier = 60 * 1000 // minutes is smallest unit + switch (unit) { + case 'm': + multiplier *= 60 // hour + break + case 'd': + multiplier *= 60 // hour + multiplier *= 24 // day + break + } + const maxAge = Number(value) * multiplier + const createdAt = Date.parse(this.status.user.latestScrobble.created_at) + const age = Date.now() - createdAt + if (age > maxAge) return false + return this.status.user.latestScrobble.artist }, scrobble () { return this.status.user.latestScrobble diff --git a/src/i18n/en.json b/src/i18n/en.json @@ -502,6 +502,7 @@ "mute_bot_posts": "Mute bot posts", "hide_actor_type_indication": "Hide actor type (bots, groups, etc.) indication in posts", "hide_scrobbles": "Hide scrobbles", + "hide_scrobbles_after": "Hide scrobbles older than", "hide_all_muted_posts": "Hide muted posts", "max_thumbnails": "Maximum amount of thumbnails per post (empty = no limit)", "hide_isp": "Hide instance-specific panel", diff --git a/src/modules/config.js b/src/modules/config.js @@ -41,6 +41,7 @@ export const defaultState = { hideAttachments: false, hideAttachmentsInConv: false, hideScrobbles: false, + hideScrobblesAfter: '2d', maxThumbnails: 16, hideNsfw: true, preloadImage: true,