mirror of
https://github.com/nextcloud/server.git
synced 2026-06-13 18:50:47 -04:00
This allows to configure which view should be the default ("start view")
in the files app, currently either "all files" or "personal files".
But it might be extended to the new home view in the future.
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
30 lines
864 B
TypeScript
30 lines
864 B
TypeScript
/**
|
|
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
import type { UserConfig } from '../types.ts'
|
|
|
|
import { loadState } from '@nextcloud/initial-state'
|
|
|
|
/**
|
|
* Check whether the personal files view can be shown
|
|
*/
|
|
export function hasPersonalFilesView(): boolean {
|
|
const storageStats = loadState('files', 'storageStats', { quota: -1 })
|
|
// Don't show this view if the user has no storage quota
|
|
return storageStats.quota !== 0
|
|
}
|
|
|
|
/**
|
|
* Get the default files view
|
|
*/
|
|
export function defaultView() {
|
|
const { default_view: defaultView } = loadState<Partial<UserConfig>>('files', 'config', { default_view: 'files' })
|
|
|
|
// the default view - only use the personal one if it is enabled
|
|
if (defaultView !== 'personal' || hasPersonalFilesView()) {
|
|
return defaultView
|
|
}
|
|
return 'files'
|
|
}
|