diff --git a/appinfo/routes.php b/appinfo/routes.php index a954653bf..bc16fec3d 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -17,7 +17,6 @@ 'name' => 'page#create', 'url' => '/new', 'verb' => 'GET', - 'postfix' => 'new', ], [ 'name' => 'page#index', diff --git a/lib/AppInfo/SearchProvider.php b/lib/AppInfo/SearchProvider.php index b56094e54..b24349b4e 100644 --- a/lib/AppInfo/SearchProvider.php +++ b/lib/AppInfo/SearchProvider.php @@ -66,7 +66,7 @@ function (Note $note) : SearchResultEntry { '', $note->getTitle(), $excerpt, - $this->url->linkToRouteAbsolute('notes.page.index') . 'note/'.$note->getId(), + $this->url->linkToRouteAbsolute('notes.page.indexnote', [ 'id' => $note->getId() ]), 'icon-notes-trans' ); }, diff --git a/lib/Controller/NotesController.php b/lib/Controller/NotesController.php index ee5ddcbae..4d8858ced 100644 --- a/lib/Controller/NotesController.php +++ b/lib/Controller/NotesController.php @@ -95,9 +95,9 @@ public function index(int $pruneBefore = 0) : JSONResponse { */ public function dashboard() : JSONResponse { return $this->helper->handleErrorResponse(function () { - $maxItems = 7; + $maxItems = 6; $userId = $this->helper->getUID(); - $notes = $this->notesService->getTopNotes($userId, $maxItems + 1); + $notes = $this->notesService->getTopNotes($userId); $hasMoreNotes = count($notes) > $maxItems; $notes = array_slice($notes, 0, $maxItems); $items = array_map(function ($note) { diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 687351352..b9baf3e0c 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -59,7 +59,7 @@ public function index() : TemplateResponse { public function create() : RedirectResponse { $note = $this->notesService->create($this->userSession->getUser()->getUID(), '', ''); $note->setContent(''); - $url = $this->urlGenerator->linkToRoute('notes.page.index', [ 'id' => $note->getId() ]); - return new RedirectResponse($url); + $url = $this->urlGenerator->linkToRoute('notes.page.indexnote', [ 'id' => $note->getId() ]); + return new RedirectResponse($url . '?new'); } } diff --git a/lib/Service/NotesService.php b/lib/Service/NotesService.php index 1c2b59223..2474f2bfb 100644 --- a/lib/Service/NotesService.php +++ b/lib/Service/NotesService.php @@ -37,7 +37,7 @@ public function getAll(string $userId) : array { return [ 'notes' => $notes, 'categories' => $data['categories'] ]; } - public function getTopNotes(string $userId, int $count) : array { + public function getTopNotes(string $userId) : array { $notes = $this->getAll($userId)['notes']; usort($notes, function (Note $a, Note $b) { $favA = $a->getFavorite(); @@ -48,7 +48,7 @@ public function getTopNotes(string $userId, int $count) : array { return $favA > $favB ? -1 : 1; } }); - return array_slice($notes, 0, $count); + return $notes; } public function get(string $userId, int $id) : Note { diff --git a/src/App.vue b/src/App.vue index 96f020ec2..50e499d89 100644 --- a/src/App.vue +++ b/src/App.vue @@ -213,11 +213,12 @@ export default { } }, - routeToNote(noteId, query) { - if (this.$route.name !== 'note' || this.$route.params.noteId !== noteId.toString()) { + routeToNote(id, query) { + const noteId = id.toString() + if (this.$route.name !== 'note' || this.$route.params.noteId !== noteId) { this.$router.push({ name: 'note', - params: { noteId: noteId.toString() }, + params: { noteId }, query, }) } @@ -228,13 +229,13 @@ export default { return } this.loading.create = true - createNote(this.filter.category || '') + createNote(this.filter.category) .then(note => { this.routeToNote(note.id, { new: null }) }) .catch(() => { }) - .then(() => { + .finally(() => { this.loading.create = false }) }, diff --git a/src/NotesService.js b/src/NotesService.js index 26a458a92..245a1ee82 100644 --- a/src/NotesService.js +++ b/src/NotesService.js @@ -179,7 +179,7 @@ export const setTitle = (noteId, title) => { export const createNote = category => { return axios - .post(url('/notes'), { category }) + .post(url('/notes'), { category: category || '' }) .then(response => { _updateLocalNote(response.data) return response.data diff --git a/src/components/Dashboard.vue b/src/components/Dashboard.vue index 9de25be1f..14df7a6f5 100644 --- a/src/components/Dashboard.vue +++ b/src/components/Dashboard.vue @@ -1,38 +1,40 @@ +