From 83ed204d9cbaddccdf008468d3e1d01415568e78 Mon Sep 17 00:00:00 2001 From: Akhil Date: Tue, 26 Sep 2023 20:08:54 +0530 Subject: [PATCH 1/5] Set default timeline path option --- lib/SystemConfigDefault.php | 3 +++ lib/Util.php | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/SystemConfigDefault.php b/lib/SystemConfigDefault.php index e1529c3e9..b4d34ec41 100644 --- a/lib/SystemConfigDefault.php +++ b/lib/SystemConfigDefault.php @@ -69,6 +69,9 @@ // 1080 => 1080p (and so on) 'memories.video_default_quality' => '0', + // Default timeline path for all users; if not set, default is '/Photos' + 'memories.default_timeline_path' => 'Photos/', + // Memories only provides an admin interface for these // https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#previews 'enabledPreviewProviders' => [], diff --git a/lib/Util.php b/lib/Util.php index bea8d0790..4710b969b 100644 --- a/lib/Util.php +++ b/lib/Util.php @@ -316,7 +316,8 @@ public static function placesGISType(): int public static function getTimelinePaths(string $uid): array { $config = \OC::$server->get(IConfig::class); - $paths = $config->getUserValue($uid, Application::APPNAME, 'timelinePath', null) ?? 'Photos/'; + $defaultTimelinePath = $config->getSystemValue('memories.default_timeline_path', 'Photos/'); + $paths = $config->getUserValue($uid, Application::APPNAME, 'timelinePath', null) ?? $defaultTimelinePath; return array_map(static fn ($p) => self::sanitizePath(trim($p)), explode(';', $paths)); } From 77cb06e67a4da01fbcefc118265ab0667fb7ebb0 Mon Sep 17 00:00:00 2001 From: Akhil Date: Tue, 26 Sep 2023 20:17:30 +0530 Subject: [PATCH 2/5] Use default_timeline_path to show first start or not --- lib/Controller/OtherController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Controller/OtherController.php b/lib/Controller/OtherController.php index 9dbd140a2..b6d379919 100644 --- a/lib/Controller/OtherController.php +++ b/lib/Controller/OtherController.php @@ -81,6 +81,7 @@ public function getUserConfig(): Http\Response return $this->config->getUserValue($uid, Application::APPNAME, $key, $default); }; + $defaultTimelinePath = $this->config->getSystemValue('memories.default_timeline_path', 'EMPTY'); return new JSONResponse([ // general stuff 'version' => $version, @@ -98,7 +99,7 @@ public function getUserConfig(): Http\Response 'preview_generator_enabled' => Util::previewGeneratorIsEnabled(), // general settings - 'timeline_path' => $getAppConfig('timelinePath', 'EMPTY'), + 'timeline_path' => $getAppConfig('timelinePath', $defaultTimelinePath), 'enable_top_memories' => 'true' === $getAppConfig('enableTopMemories', 'true'), // viewer settings From 6b4983fc2878149ffd6d4c46456b2715daee0e99 Mon Sep 17 00:00:00 2001 From: Akhil Date: Tue, 26 Sep 2023 20:36:49 +0530 Subject: [PATCH 3/5] use getsystemconfig method --- lib/Util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Util.php b/lib/Util.php index 4710b969b..6cfc05a40 100644 --- a/lib/Util.php +++ b/lib/Util.php @@ -316,7 +316,7 @@ public static function placesGISType(): int public static function getTimelinePaths(string $uid): array { $config = \OC::$server->get(IConfig::class); - $defaultTimelinePath = $config->getSystemValue('memories.default_timeline_path', 'Photos/'); + $defaultTimelinePath = self::getSystemConfig('memories.default_timeline_path'); $paths = $config->getUserValue($uid, Application::APPNAME, 'timelinePath', null) ?? $defaultTimelinePath; return array_map(static fn ($p) => self::sanitizePath(trim($p)), explode(';', $paths)); From 269d080df1869f3619b597828502278085e94713 Mon Sep 17 00:00:00 2001 From: Akhil Date: Tue, 26 Sep 2023 23:17:28 +0530 Subject: [PATCH 4/5] lint fix --- lib/Controller/OtherController.php | 1 + lib/SystemConfigDefault.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Controller/OtherController.php b/lib/Controller/OtherController.php index b6d379919..673779f67 100644 --- a/lib/Controller/OtherController.php +++ b/lib/Controller/OtherController.php @@ -82,6 +82,7 @@ public function getUserConfig(): Http\Response }; $defaultTimelinePath = $this->config->getSystemValue('memories.default_timeline_path', 'EMPTY'); + return new JSONResponse([ // general stuff 'version' => $version, diff --git a/lib/SystemConfigDefault.php b/lib/SystemConfigDefault.php index b4d34ec41..989c0a2d8 100644 --- a/lib/SystemConfigDefault.php +++ b/lib/SystemConfigDefault.php @@ -69,7 +69,7 @@ // 1080 => 1080p (and so on) 'memories.video_default_quality' => '0', - // Default timeline path for all users; if not set, default is '/Photos' + // Default timeline path for all users; if not set, default is '/Photos' 'memories.default_timeline_path' => 'Photos/', // Memories only provides an admin interface for these From 630a435deaf0f69766d67eb34d8ce1dd16aa6625 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Fri, 29 Sep 2023 11:00:44 -0700 Subject: [PATCH 5/5] Refactor PR --- lib/Controller/OtherController.php | 4 +--- lib/SystemConfigDefault.php | 7 ++++--- lib/Util.php | 4 ++-- src/App.vue | 8 ++++++-- src/services/static-config.ts | 2 +- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/Controller/OtherController.php b/lib/Controller/OtherController.php index 673779f67..3f5328f53 100644 --- a/lib/Controller/OtherController.php +++ b/lib/Controller/OtherController.php @@ -81,8 +81,6 @@ public function getUserConfig(): Http\Response return $this->config->getUserValue($uid, Application::APPNAME, $key, $default); }; - $defaultTimelinePath = $this->config->getSystemValue('memories.default_timeline_path', 'EMPTY'); - return new JSONResponse([ // general stuff 'version' => $version, @@ -100,7 +98,7 @@ public function getUserConfig(): Http\Response 'preview_generator_enabled' => Util::previewGeneratorIsEnabled(), // general settings - 'timeline_path' => $getAppConfig('timelinePath', $defaultTimelinePath), + 'timeline_path' => $getAppConfig('timelinePath', Util::getSystemConfig('memories.timeline.default_path')), 'enable_top_memories' => 'true' === $getAppConfig('enableTopMemories', 'true'), // viewer settings diff --git a/lib/SystemConfigDefault.php b/lib/SystemConfigDefault.php index d5f3cbe6c..c3285ca5a 100644 --- a/lib/SystemConfigDefault.php +++ b/lib/SystemConfigDefault.php @@ -21,6 +21,10 @@ // Places database type identifier 'memories.gis_type' => -1, + // Default timeline path for all users + // If set to '_empty_', the user is prompted to select a path on first open (default) + 'memories.timeline.default_path' => '_empty_', + // Default viewer high resolution image loading condition // Valid values: 'always' | 'zoom' | 'never' 'memories.viewer.high_res_cond_default' => 'zoom', @@ -70,9 +74,6 @@ // 1080 => 1080p (and so on) 'memories.video_default_quality' => '0', - // Default timeline path for all users; if not set, default is '/Photos' - 'memories.default_timeline_path' => 'Photos/', - // Memories only provides an admin interface for these // https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#previews 'enabledPreviewProviders' => [], diff --git a/lib/Util.php b/lib/Util.php index 6cfc05a40..28f593174 100644 --- a/lib/Util.php +++ b/lib/Util.php @@ -316,8 +316,8 @@ public static function placesGISType(): int public static function getTimelinePaths(string $uid): array { $config = \OC::$server->get(IConfig::class); - $defaultTimelinePath = self::getSystemConfig('memories.default_timeline_path'); - $paths = $config->getUserValue($uid, Application::APPNAME, 'timelinePath', null) ?? $defaultTimelinePath; + $paths = $config->getUserValue($uid, Application::APPNAME, 'timelinePath', null) + ?? self::getSystemConfig('memories.timeline.default_path'); return array_map(static fn ($p) => self::sanitizePath(trim($p)), explode(';', $paths)); } diff --git a/src/App.vue b/src/App.vue index 732062477..fba4d74a9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,7 +3,7 @@