From def68e9cda881447bb2d278248635d7ff4f2498f Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 25 Mar 2024 23:34:19 +0200 Subject: scrobbles age setting --- src/components/status/status.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/components/status/status.js') 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 -- cgit v1.2.3-70-g09d2 From 4de9daa1144536f03c86d277b4ec1288dc9df432 Mon Sep 17 00:00:00 2001 From: marcin mikołajczak Date: Sun, 28 Apr 2024 18:56:10 +0000 Subject: Apply 1 suggestion(s) to 1 file(s) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: marcin mikołajczak --- src/components/status/status.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/components/status/status.js') diff --git a/src/components/status/status.js b/src/components/status/status.js index 36f6c602..43181897 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -421,6 +421,8 @@ const Status = { let multiplier = 60 * 1000 // minutes is smallest unit switch (unit) { case 'm': + break + case 'h': multiplier *= 60 // hour break case 'd': -- cgit v1.2.3-70-g09d2