From 1750e5693f9f55c6fbe96a64000c0b4841e8d2ee Mon Sep 17 00:00:00 2001 From: flashwave Date: Fri, 6 Oct 2023 21:24:24 +0000 Subject: [PATCH] Fixed crash on profiles. --- src/Users/ProfileRoutes.php | 11 ++++++++++- templates/macros.twig | 3 +-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Users/ProfileRoutes.php b/src/Users/ProfileRoutes.php index 9754dfc..82e3e16 100644 --- a/src/Users/ProfileRoutes.php +++ b/src/Users/ProfileRoutes.php @@ -33,7 +33,16 @@ class ProfileRoutes extends RouteHandler { return 404; } - $submissions = $torrents->getTorrents(approved: true, userInfo: $userInfo, take: 3); + $submissions = []; + $torrentInfos = $torrents->getTorrents(approved: true, userInfo: $userInfo, take: 3); + foreach($torrentInfos as $torrentInfo) { + $submissions[] = [ + 'info' => $torrentInfo, + 'complete_peers' => $peers->countCompletePeers($torrentInfo), + 'incomplete_peers' => $peers->countIncompletePeers($torrentInfo), + ]; + } + $uploading = $peers->countUserUploading($userInfo); $downloading = $peers->countUserDownloading($userInfo); diff --git a/templates/macros.twig b/templates/macros.twig index fed34ef..2a84aff 100644 --- a/templates/macros.twig +++ b/templates/macros.twig @@ -1,6 +1,6 @@ {% macro torrent_listing_entry(torrent, class_name) %} {% set torrent_info = torrent.info %} - {% set submitter_info = torrent.user %} + {% set submitter_info = torrent.user|default(null) %}
@@ -14,7 +14,6 @@ {% endif %}
-
{{ torrent.complete_peers|number_format }}
{{ torrent.incomplete_peers|number_format }}