diff options
| author | Henry Jameson <me@hjkos.com> | 2024-03-25 23:34:19 +0200 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2024-03-25 23:35:28 +0200 |
| commit | def68e9cda881447bb2d278248635d7ff4f2498f (patch) | |
| tree | 736e37c6ec696f4e7c1f096939fd5043703e70f9 | |
| parent | 23edfe7b918844f8cc2ff5b9b245952092ee1cbf (diff) | |
scrobbles age setting
| -rw-r--r-- | src/components/settings_modal/tabs/filtering_tab.js | 2 | ||||
| -rw-r--r-- | src/components/settings_modal/tabs/filtering_tab.vue | 10 | ||||
| -rw-r--r-- | src/components/status/status.js | 20 | ||||
| -rw-r--r-- | src/i18n/en.json | 1 | ||||
| -rw-r--r-- | src/modules/config.js | 1 |
5 files changed, 33 insertions, 1 deletions
diff --git a/src/components/settings_modal/tabs/filtering_tab.js b/src/components/settings_modal/tabs/filtering_tab.js index 7c37f0bc..06f238af 100644 --- 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 index 9e82fcfd..0f796255 100644 --- 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 index 8f22b708..36f6c602 100644 --- 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 index affe4335..b1b39cc2 100644 --- 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 index abb57272..23ee152c 100644 --- 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, |
