initialize settings when using API or starting app

This commit is contained in:
korelstar 2022-08-14 10:48:26 +02:00
parent bab1e774da
commit 67edbc1ffd
4 changed files with 9 additions and 2 deletions

View File

@ -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

View File

@ -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'];

View File

@ -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(

View File

@ -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;
}