aboutsummaryrefslogtreecommitdiff
path: root/src/components/status
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2024-03-25 23:34:19 +0200
committerHenry Jameson <me@hjkos.com>2024-03-25 23:35:28 +0200
commitdef68e9cda881447bb2d278248635d7ff4f2498f (patch)
tree736e37c6ec696f4e7c1f096939fd5043703e70f9 /src/components/status
parent23edfe7b918844f8cc2ff5b9b245952092ee1cbf (diff)
scrobbles age setting
Diffstat (limited to 'src/components/status')
-rw-r--r--src/components/status/status.js20
1 files changed, 19 insertions, 1 deletions
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