From b894fe93fafecb7ee6dd2d81470db544706884ec Mon Sep 17 00:00:00 2001 From: Daniel Nitsikopoulos Date: Fri, 24 May 2024 20:30:42 +1000 Subject: [PATCH] Hide recent media on now page if requests fail --- .../templates/recently_played/index.html.slim | 22 ++++++++++--------- .../recently_played_games/index.html.slim | 17 ++++++++------ slices/main/views/recently_played/index.rb | 1 - 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/slices/main/templates/recently_played/index.html.slim b/slices/main/templates/recently_played/index.html.slim index d8a88c7..88372ef 100644 --- a/slices/main/templates/recently_played/index.html.slim +++ b/slices/main/templates/recently_played/index.html.slim @@ -1,10 +1,12 @@ -div class="grid grid-cols-4 gap-2" - - recently_played_music.each do |album| - a href="#{album[:href]}" - div - img class="m-0 rounded transition-transform ease-out hover:scale-105" src="#{album[:image]}" - span class="inline-block text-sm" - = album[:name] - br - span class="inline-block text-sm font-bold" - = album[:artist] \ No newline at end of file +- if recently_played_music.count > 0 + h3 🎧 Recently listened to + div class="grid grid-cols-4 gap-2" + - recently_played_music.each do |album| + a href="#{album[:href]}" + div + img class="m-0 rounded transition-transform ease-out hover:scale-105" src="#{album[:image]}" + span class="inline-block text-sm" + = album[:name] + br + span class="inline-block text-sm font-bold" + = album[:artist] diff --git a/slices/main/templates/recently_played_games/index.html.slim b/slices/main/templates/recently_played_games/index.html.slim index 3f3e834..3278ff8 100644 --- a/slices/main/templates/recently_played_games/index.html.slim +++ b/slices/main/templates/recently_played_games/index.html.slim @@ -1,8 +1,11 @@ -table - - recently_played_games.each do |game| - tr - td - = game[:name] +- if recently_played_games.count > 0 + h3 👾 Recently played on Steam - td - = "(#{game[:playtime_forever]}hrs total)" \ No newline at end of file + table + - recently_played_games.each do |game| + tr + td + = game[:name] + + td + = "(#{game[:playtime_forever]}hrs total)" diff --git a/slices/main/views/recently_played/index.rb b/slices/main/views/recently_played/index.rb index c17abb0..158d362 100644 --- a/slices/main/views/recently_played/index.rb +++ b/slices/main/views/recently_played/index.rb @@ -7,7 +7,6 @@ module Main include Deps["queries.posts.recently_played"] expose :recently_played_music do |recently_played_result| - # raise recently_played_result["data"].inspect JSON.parse(recently_played_result)["data"].reject { |a| a["type"] != "albums" }.map do |album| { artist: album["attributes"]["artistName"],