Skip to content

Commit

Permalink
Refactor PR
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsejet committed Sep 29, 2023
1 parent 6947ee9 commit 630a435
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
4 changes: 1 addition & 3 deletions lib/Controller/OtherController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions lib/SystemConfigDefault.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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' => [],
Expand Down
4 changes: 2 additions & 2 deletions lib/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
8 changes: 6 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<NcContent
app-name="memories"
v-else
v-else-if="!isConfigUnknown"
:class="{
'remove-gap': removeOuterGap,
'has-nav': showNavigation,
Expand Down Expand Up @@ -187,7 +187,11 @@ export default defineComponent({
},
isFirstStart(): boolean {
return this.config.timeline_path === 'EMPTY' && !this.routeIsPublic && !this.$route.query.noinit;
return this.config.timeline_path === '_empty_' && !this.routeIsPublic && !this.$route.query.noinit;
},
isConfigUnknown(): boolean {
return this.config.timeline_path === '_unknown_';
},
showAlbums(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/services/static-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class StaticConfig {
preview_generator_enabled: false,

// general settings
timeline_path: '',
timeline_path: '_unknown_',
enable_top_memories: true,

// viewer settings
Expand Down

0 comments on commit 630a435

Please sign in to comment.