From 45fa284b75108c1d7ddca61e6998f4108c72c440 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Thu, 6 Jul 2023 13:18:59 -0700 Subject: [PATCH] albums: fix name for shares (fix #723) Signed-off-by: Varun Patil --- lib/ClustersBackend/AlbumsBackend.php | 7 +++++ lib/Db/AlbumsQuery.php | 11 +++++++- src/components/frame/Cluster.vue | 2 +- src/components/modal/AlbumPicker.vue | 40 +++++++++++++++------------ src/types.ts | 2 ++ 5 files changed, 43 insertions(+), 19 deletions(-) diff --git a/lib/ClustersBackend/AlbumsBackend.php b/lib/ClustersBackend/AlbumsBackend.php index 90e6cecb..2c09146d 100644 --- a/lib/ClustersBackend/AlbumsBackend.php +++ b/lib/ClustersBackend/AlbumsBackend.php @@ -113,6 +113,13 @@ class AlbumsBackend extends Backend return true; }); + // Add display names for users + $userManager = \OC::$server->get(\OCP\IUserManager::class); + array_walk($list, function (&$item) use ($userManager) { + $user = $userManager->get($item['user']); + $item['user_display'] = $user ? $user->getDisplayName() : null; + }); + // Convert $list to sequential array return array_values($list); } diff --git a/lib/Db/AlbumsQuery.php b/lib/Db/AlbumsQuery.php index dd1fd26d..830b73fc 100644 --- a/lib/Db/AlbumsQuery.php +++ b/lib/Db/AlbumsQuery.php @@ -23,7 +23,16 @@ class AlbumsQuery // SELECT everything from albums $count = $query->func()->count($query->createFunction('DISTINCT m.fileid'), 'count'); - $query->select('pa.*', $count)->from('photos_albums', 'pa'); + $query->select( + 'pa.album_id', + 'pa.name', + 'pa.user', + 'pa.created', + 'pa.created', + 'pa.location', + 'pa.last_added_photo', + $count + )->from('photos_albums', 'pa'); if ($shared) { $ids = $this->getSelfCollaborators($uid); diff --git a/src/components/frame/Cluster.vue b/src/components/frame/Cluster.vue index f0e6dce3..80c28672 100644 --- a/src/components/frame/Cluster.vue +++ b/src/components/frame/Cluster.vue @@ -84,7 +84,7 @@ export default defineComponent({ subtitle() { if (this.album && this.album.user !== getCurrentUser()?.uid) { - return `(${this.album.user})`; + return `(${this.album.user_display || this.album.user})`; } return ''; diff --git a/src/components/modal/AlbumPicker.vue b/src/components/modal/AlbumPicker.vue index c505df9b..eb0c75b8 100644 --- a/src/components/modal/AlbumPicker.vue +++ b/src/components/modal/AlbumPicker.vue @@ -5,33 +5,31 @@