Skip to content

Commit

Permalink
fix(RecentPagesService): Add title for landing page and add fileId to…
Browse files Browse the repository at this point in the history
… links

Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Nov 7, 2023
1 parent eb8dc30 commit ac9098c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/Service/RecentPagesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use OCP\Files\IMimeTypeLoader;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUser;

Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ac9098c

Please sign in to comment.