aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHJ <30-hj@users.noreply.git.pleroma.social>2024-05-22 12:25:24 +0000
committerHJ <30-hj@users.noreply.git.pleroma.social>2024-05-22 12:25:24 +0000
commitfd1011f622870385d8a694d60b66269e731b36cd (patch)
tree57e6766d33235f1a2c16af7ff21260cb46777c99
parent3e99006e2ab06d2c8ade2eb20e12b1d2fbbcaac2 (diff)
parenteb27f1205b7bf077b81d698d24c2be656cc59023 (diff)
Merge branch 'scrobbles-age' into 'develop'
Add setting to only show scrobbles newer than certain age. See merge request pleroma/pleroma-fe!1904
-rw-r--r--changelog.d/scrobbles-age-filter.add1
-rw-r--r--src/components/settings_modal/helpers/unit_setting.js (renamed from src/components/settings_modal/helpers/size_setting.js)8
-rw-r--r--src/components/settings_modal/helpers/unit_setting.vue (renamed from src/components/settings_modal/helpers/size_setting.vue)19
-rw-r--r--src/components/settings_modal/settings_modal_admin_content.scss4
-rw-r--r--src/components/settings_modal/settings_modal_user_content.scss4
-rw-r--r--src/components/settings_modal/tabs/filtering_tab.js2
-rw-r--r--src/components/settings_modal/tabs/filtering_tab.vue11
-rw-r--r--src/components/settings_modal/tabs/general_tab.js4
-rw-r--r--src/components/settings_modal/tabs/general_tab.vue4
-rw-r--r--src/components/status/status.js22
-rw-r--r--src/i18n/en.json9
-rw-r--r--src/modules/config.js1
12 files changed, 66 insertions, 23 deletions
diff --git a/changelog.d/scrobbles-age-filter.add b/changelog.d/scrobbles-age-filter.add
new file mode 100644
index 00000000..ecd3c7d8
--- /dev/null
+++ b/changelog.d/scrobbles-age-filter.add
@@ -0,0 +1 @@
+Option to only show scrobbles that are recent enough
diff --git a/src/components/settings_modal/helpers/size_setting.js b/src/components/settings_modal/helpers/unit_setting.js
index 12cef705..c9c23cb0 100644
--- a/src/components/settings_modal/helpers/size_setting.js
+++ b/src/components/settings_modal/helpers/unit_setting.js
@@ -17,6 +17,10 @@ export default {
units: {
type: Array,
default: () => allCssUnits
+ },
+ unitSet: {
+ type: String,
+ default: 'none'
}
},
computed: {
@@ -30,6 +34,10 @@ export default {
},
methods: {
...Setting.methods,
+ getUnitString (value) {
+ if (this.unitSet === 'none') return value
+ return this.$t(['settings', 'units', this.unitSet, value].join('.'))
+ },
updateValue (e) {
this.configSink(this.path, parseInt(e.target.value) + this.stateUnit)
},
diff --git a/src/components/settings_modal/helpers/size_setting.vue b/src/components/settings_modal/helpers/unit_setting.vue
index 0a2206b2..68f52b1c 100644
--- a/src/components/settings_modal/helpers/size_setting.vue
+++ b/src/components/settings_modal/helpers/unit_setting.vue
@@ -1,7 +1,7 @@
<template>
<span
v-if="matchesExpertLevel"
- class="SizeSetting"
+ class="UnitSetting"
>
<label
:for="path"
@@ -23,7 +23,7 @@
:id="path"
:model-value="stateUnit"
:disabled="disabled"
- class="css-unit-input"
+ class="unit-input unstyled"
@change="updateUnit"
>
<option
@@ -31,7 +31,7 @@
:key="option"
:value="option"
>
- {{ option }}
+ {{ getUnitString(option) }}
</option>
</Select>
{{ ' ' }}
@@ -42,20 +42,19 @@
</span>
</template>
-<script src="./size_setting.js"></script>
+<script src="./unit_setting.js"></script>
<style lang="scss">
-.SizeSetting {
+.UnitSetting {
.number-input {
max-width: 6.5em;
+ text-align: right;
}
- .css-unit-input,
- .css-unit-input select {
- margin-left: 0.5em;
- width: 4em;
- max-width: 4em;
+ .unit-input,
+ .unit-input select {
min-width: 4em;
+ width: auto;
}
}
diff --git a/src/components/settings_modal/settings_modal_admin_content.scss b/src/components/settings_modal/settings_modal_admin_content.scss
index bd619d7f..a5314fe1 100644
--- a/src/components/settings_modal/settings_modal_admin_content.scss
+++ b/src/components/settings_modal/settings_modal_admin_content.scss
@@ -31,10 +31,6 @@
margin-bottom: 1em;
}
- select {
- min-width: 10em;
- }
-
textarea {
width: 100%;
max-width: 100%;
diff --git a/src/components/settings_modal/settings_modal_user_content.scss b/src/components/settings_modal/settings_modal_user_content.scss
index bd619d7f..a5314fe1 100644
--- a/src/components/settings_modal/settings_modal_user_content.scss
+++ b/src/components/settings_modal/settings_modal_user_content.scss
@@ -31,10 +31,6 @@
margin-bottom: 1em;
}
- select {
- min-width: 10em;
- }
-
textarea {
width: 100%;
max-width: 100%;
diff --git a/src/components/settings_modal/tabs/filtering_tab.js b/src/components/settings_modal/tabs/filtering_tab.js
index 7c37f0bc..fbace15d 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 UnitSetting from '../helpers/unit_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,
+ UnitSetting,
IntegerSetting
},
computed: {
diff --git a/src/components/settings_modal/tabs/filtering_tab.vue b/src/components/settings_modal/tabs/filtering_tab.vue
index 1f2c0363..821ca750 100644
--- a/src/components/settings_modal/tabs/filtering_tab.vue
+++ b/src/components/settings_modal/tabs/filtering_tab.vue
@@ -119,6 +119,17 @@
{{ $t('settings.hide_scrobbles') }}
</BooleanSetting>
</li>
+ <li>
+ <UnitSetting
+ key="hideScrobblesAfter"
+ path="hideScrobblesAfter"
+ :units="['m', 'h', 'd']"
+ unitSet="time"
+ expert="1"
+ >
+ {{ $t('settings.hide_scrobbles_after') }}
+ </UnitSetting>
+ </li>
</ul>
</div>
<div
diff --git a/src/components/settings_modal/tabs/general_tab.js b/src/components/settings_modal/tabs/general_tab.js
index 3f2bcb13..7d701d34 100644
--- a/src/components/settings_modal/tabs/general_tab.js
+++ b/src/components/settings_modal/tabs/general_tab.js
@@ -3,7 +3,7 @@ import ChoiceSetting from '../helpers/choice_setting.vue'
import ScopeSelector from 'src/components/scope_selector/scope_selector.vue'
import IntegerSetting from '../helpers/integer_setting.vue'
import FloatSetting from '../helpers/float_setting.vue'
-import SizeSetting, { defaultHorizontalUnits } from '../helpers/size_setting.vue'
+import UnitSetting, { defaultHorizontalUnits } from '../helpers/unit_setting.vue'
import InterfaceLanguageSwitcher from 'src/components/interface_language_switcher/interface_language_switcher.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js'
@@ -64,7 +64,7 @@ const GeneralTab = {
ChoiceSetting,
IntegerSetting,
FloatSetting,
- SizeSetting,
+ UnitSetting,
InterfaceLanguageSwitcher,
ScopeSelector,
ProfileSettingIndicator
diff --git a/src/components/settings_modal/tabs/general_tab.vue b/src/components/settings_modal/tabs/general_tab.vue
index 424ee7e4..208c49ee 100644
--- a/src/components/settings_modal/tabs/general_tab.vue
+++ b/src/components/settings_modal/tabs/general_tab.vue
@@ -134,7 +134,7 @@
<li v-if="expertLevel > 0">
{{ $t('settings.column_sizes') }}
<div class="column-settings">
- <SizeSetting
+ <UnitSetting
v-for="column in columns"
:key="column"
:path="column + 'ColumnWidth'"
@@ -142,7 +142,7 @@
expert="1"
>
{{ $t('settings.column_sizes_' + column) }}
- </SizeSetting>
+ </UnitSetting>
</div>
</li>
<li class="select-multiple">
diff --git a/src/components/status/status.js b/src/components/status/status.js
index 85a41a9a..bf4e4275 100644
--- a/src/components/status/status.js
+++ b/src/components/status/status.js
@@ -425,7 +425,27 @@ 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':
+ break
+ case 'h':
+ 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 270e14bd..f626e933 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -395,6 +395,14 @@
"desc": "To enable two-factor authentication, enter the code from your two-factor app:"
}
},
+ "units": {
+ "time": {
+ "m": "minutes",
+ "s": "seconds",
+ "h": "hours",
+ "d": "days"
+ }
+ },
"lists_navigation": "Show lists in navigation",
"allow_following_move": "Allow auto-follow when following account moves",
"attachmentRadius": "Attachments",
@@ -502,6 +510,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",
"mute_sensitive_posts": "Mute sensitive posts",
"hide_all_muted_posts": "Hide muted posts",
"max_thumbnails": "Maximum amount of thumbnails per post (empty = no limit)",
diff --git a/src/modules/config.js b/src/modules/config.js
index 75b1a0c4..8001b854 100644
--- a/src/modules/config.js
+++ b/src/modules/config.js
@@ -43,6 +43,7 @@ export const defaultState = {
hideAttachments: false,
hideAttachmentsInConv: false,
hideScrobbles: false,
+ hideScrobblesAfter: '2d',
maxThumbnails: 16,
hideNsfw: true,
preloadImage: true,