Merge pull request #58908 from nextcloud/feat/1701/recent-files-img-grouping

feat(recent-files): allow configuring image grouping
This commit is contained in:
Louis 2026-04-16 12:00:02 +02:00 committed by GitHub
commit 8598f8b171
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 2 deletions

View file

@ -23,6 +23,9 @@ use OCP\Config\ValueType;
class ConfigLexicon implements ILexicon {
public const OVERWRITES_HOME_FOLDERS = 'overwrites_home_folders';
public const RECENT_LIMIT = 'recent_limit';
public const GROUP_RECENT_FILES = 'group_recent_files';
public const RECENT_FILES_GROUP_MIME_TYPES = 'recent_files_group_mime_types';
public const RECENT_FILES_GROUP_TIMESPAN_MINUTES = 'recent_files_group_timespan_minutes';
public function getStrictness(): Strictness {
return Strictness::IGNORE;
@ -45,6 +48,27 @@ class ConfigLexicon implements ILexicon {
definition: 'Maximum number of files to display on recent files view',
lazy: false,
),
new Entry(
self::GROUP_RECENT_FILES,
ValueType::BOOL,
defaultRaw: false,
definition: 'Whether to group recent files by MIME type or not',
lazy: false,
),
new Entry(
self::RECENT_FILES_GROUP_MIME_TYPES,
ValueType::ARRAY,
defaultRaw: [],
definition: 'Which MIME types to group in the recent files list',
lazy: false,
),
new Entry(
self::RECENT_FILES_GROUP_TIMESPAN_MINUTES,
ValueType::INT,
defaultRaw: 2,
definition: 'Time window in minutes to group files uploaded close together in the recent files list',
lazy: false,
),
];
}

View file

@ -178,6 +178,10 @@ class ViewController extends Controller {
$this->initialState->provideInitialState('config', $this->userConfig->getConfigs());
$this->initialState->provideInitialState('viewConfigs', $this->viewConfig->getConfigs());
$this->initialState->provideInitialState('recent_limit', $this->appConfig->getAppValueInt(ConfigLexicon::RECENT_LIMIT, 100));
// Not yet consumed by the frontend, provided for future implementation
$this->initialState->provideInitialState('group_recent_files', $this->appConfig->getAppValueBool(ConfigLexicon::GROUP_RECENT_FILES, false));
$this->initialState->provideInitialState('recent_files_group_mime_types', $this->appConfig->getAppValueArray(ConfigLexicon::RECENT_FILES_GROUP_MIME_TYPES, []));
$this->initialState->provideInitialState('recent_files_group_timespan_minutes', $this->appConfig->getAppValueInt(ConfigLexicon::RECENT_FILES_GROUP_TIMESPAN_MINUTES, 2));
// File sorting user config
$filesSortingConfig = json_decode($this->config->getUserValue($userId, 'files', 'files_sorting_configs', '{}'), true);

View file

@ -302,11 +302,11 @@ class ViewControllerTest extends TestCase {
'backup_codes' => true,
]);
$invokedCountProvideInitialState = $this->exactly(10);
$invokedCountProvideInitialState = $this->exactly(13);
$this->initialState->expects($invokedCountProvideInitialState)
->method('provideInitialState')
->willReturnCallback(function ($key, $data) use ($invokedCountProvideInitialState): void {
if ($invokedCountProvideInitialState->numberOfInvocations() === 10) {
if ($invokedCountProvideInitialState->numberOfInvocations() === 13) {
$this->assertEquals('isTwoFactorEnabled', $key);
$this->assertTrue($data);
}