aboutsummaryrefslogtreecommitdiff
path: root/src/components/status/status.js
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 /src/components/status/status.js
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
Diffstat (limited to 'src/components/status/status.js')
-rw-r--r--src/components/status/status.js22
1 files changed, 21 insertions, 1 deletions
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