Skip to content

Commit 67edbc1

Browse files
committed
initialize settings when using API or starting app
1 parent bab1e77 commit 67edbc1

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

lib/Controller/Helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function getNotesAndCategories(
7474
$userId = $this->getUID();
7575
$chunkCursor = $chunkCursorStr ? ChunkCursor::fromString($chunkCursorStr) : null;
7676
$lastUpdate = $chunkCursor->timeStart ?? new \DateTime();
77-
$data = $this->notesService->getAll($userId, true);
77+
$data = $this->notesService->getAll($userId, true); // auto-create notes folder if not exists
7878
$metaNotes = $this->metaService->getAll($userId, $data['notes']);
7979

8080
// if a category is requested, then ignore all other notes

lib/Controller/NotesApiController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public function index(
5555
$chunkSize,
5656
$chunkCursor
5757
) {
58+
// initialize settings
59+
$userId = $this->helper->getUID();
60+
$this->settingsService->getAll($userId, true);
61+
// load notes and categories
5862
$exclude = explode(',', $exclude);
5963
$data = $this->helper->getNotesAndCategories($pruneBefore, $exclude, $category, $chunkSize, $chunkCursor);
6064
$notesData = $data['notesData'];

lib/Controller/NotesController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public function __construct(
4949
public function index(int $pruneBefore = 0) : JSONResponse {
5050
return $this->helper->handleErrorResponse(function () use ($pruneBefore) {
5151
$userId = $this->helper->getUID();
52+
// initialize and load settings
5253
$settings = $this->settingsService->getAll($userId, true);
5354

5455
$lastViewedNote = (int) $this->settings->getUserValue(

lib/Service/SettingsService.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ public function get(string $uid, string $name) : string {
168168
}
169169

170170
public function getPublic(string $uid) : \stdClass {
171-
$settings = $this->getAll($uid);
171+
// initialize and load settings
172+
$settings = $this->getAll($uid, true);
173+
// translate internal settings to public settings
172174
if ($settings->fileSuffix === 'custom') {
173175
$settings->fileSuffix = $settings->customSuffix;
174176
}

0 commit comments

Comments
 (0)