diff options
author | korelstar <korelstar@users.noreply.github.com> | 2022-08-14 11:48:26 +0300 |
---|---|---|
committer | korelstar <korelstar@users.noreply.github.com> | 2022-08-14 11:57:55 +0300 |
commit | 67edbc1ffd048d40b477fa9d39c7386752e60665 (patch) | |
tree | 1e61f0212b07c78b9fdbf4897e6263c674750c55 | |
parent | bab1e774da361d91217813856e290203870eebf1 (diff) |
initialize settings when using API or starting app
-rw-r--r-- | lib/Controller/Helper.php | 2 | ||||
-rw-r--r-- | lib/Controller/NotesApiController.php | 4 | ||||
-rw-r--r-- | lib/Controller/NotesController.php | 1 | ||||
-rw-r--r-- | lib/Service/SettingsService.php | 4 |
4 files changed, 9 insertions, 2 deletions
diff --git a/lib/Controller/Helper.php b/lib/Controller/Helper.php index ff416e80..ca3df1ae 100644 --- a/lib/Controller/Helper.php +++ b/lib/Controller/Helper.php @@ -74,7 +74,7 @@ class Helper { $userId = $this->getUID(); $chunkCursor = $chunkCursorStr ? ChunkCursor::fromString($chunkCursorStr) : null; $lastUpdate = $chunkCursor->timeStart ?? new \DateTime(); - $data = $this->notesService->getAll($userId, true); + $data = $this->notesService->getAll($userId, true); // auto-create notes folder if not exists $metaNotes = $this->metaService->getAll($userId, $data['notes']); // if a category is requested, then ignore all other notes diff --git a/lib/Controller/NotesApiController.php b/lib/Controller/NotesApiController.php index 62c6ad19..2c869c53 100644 --- a/lib/Controller/NotesApiController.php +++ b/lib/Controller/NotesApiController.php @@ -55,6 +55,10 @@ class NotesApiController extends ApiController { $chunkSize, $chunkCursor ) { + // initialize settings + $userId = $this->helper->getUID(); + $this->settingsService->getAll($userId, true); + // load notes and categories $exclude = explode(',', $exclude); $data = $this->helper->getNotesAndCategories($pruneBefore, $exclude, $category, $chunkSize, $chunkCursor); $notesData = $data['notesData']; diff --git a/lib/Controller/NotesController.php b/lib/Controller/NotesController.php index a78aa50c..15460398 100644 --- a/lib/Controller/NotesController.php +++ b/lib/Controller/NotesController.php @@ -49,6 +49,7 @@ class NotesController extends Controller { public function index(int $pruneBefore = 0) : JSONResponse { return $this->helper->handleErrorResponse(function () use ($pruneBefore) { $userId = $this->helper->getUID(); + // initialize and load settings $settings = $this->settingsService->getAll($userId, true); $lastViewedNote = (int) $this->settings->getUserValue( diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index bbc8e718..d3bdbdbd 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -168,7 +168,9 @@ class SettingsService { } public function getPublic(string $uid) : \stdClass { - $settings = $this->getAll($uid); + // initialize and load settings + $settings = $this->getAll($uid, true); + // translate internal settings to public settings if ($settings->fileSuffix === 'custom') { $settings->fileSuffix = $settings->customSuffix; } |