From ac9098cb3780872a86e9d6e1332baeb3d22fbf92 Mon Sep 17 00:00:00 2001 From: Jonas Date: Tue, 7 Nov 2023 16:31:03 +0100 Subject: [PATCH] fix(RecentPagesService): Add title for landing page and add fileId to links Signed-off-by: Jonas --- lib/Service/RecentPagesService.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/Service/RecentPagesService.php b/lib/Service/RecentPagesService.php index a4935d088..a60912df1 100644 --- a/lib/Service/RecentPagesService.php +++ b/lib/Service/RecentPagesService.php @@ -11,6 +11,7 @@ use OCP\Files\IMimeTypeLoader; use OCP\IConfig; use OCP\IDBConnection; +use OCP\IL10N; use OCP\IURLGenerator; use OCP\IUser; @@ -21,19 +22,22 @@ class RecentPagesService { protected IDBConnection $dbc; protected IConfig $config; protected IMimeTypeLoader $mimeTypeLoader; + protected IL10N $l10n; public function __construct( CollectiveService $collectiveService, IDBConnection $dbc, IConfig $config, IMimeTypeLoader $mimeTypeLoader, - IURLGenerator $urlGenerator + IURLGenerator $urlGenerator, + IL10N $l10n ) { $this->mimeTypeLoader = $mimeTypeLoader; $this->config = $config; $this->dbc = $dbc; $this->urlGenerator = $urlGenerator; $this->collectiveService = $collectiveService; + $this->l10n = $l10n; } /** @@ -91,10 +95,14 @@ public function forUser(IUser $user, int $limit = 10): array { if ($row['filename'] !== 'Readme.md') { $pathParts[] = basename($row['filename'], PageInfo::SUFFIX); $title = basename($row['filename'], PageInfo::SUFFIX); + } elseif ($internalPath === '' || $internalPath === '.') { + $title = $this->l10n->t('Landing page'); } else { $title = basename($internalPath); } - $url = $this->urlGenerator->linkToRoute('collectives.start.indexPath', ['path' => implode('/', $pathParts)]); + + $fileIdSuffix = '?fileId=' . $row['file_id']; + $url = $this->urlGenerator->linkToRoute('collectives.start.indexPath', ['path' => implode('/', $pathParts)]) . $fileIdSuffix; // build result model // not returning a PageInfo instance because it would be either incomplete or too expensive to build completely