Fix issue loading new note
authorAdam Dullage <redacted>
Tue, 7 May 2024 11:41:05 +0000 (12:41 +0100)
committerAdam Dullage <redacted>
Tue, 7 May 2024 11:41:05 +0000 (12:41 +0100)
client/views/Note.vue
client/views/SearchResults.vue

index 3a6bb943fe5ea0fd1a53b525e26c65b89900883d..0ba885fb79cb0e75cff17ec5673a9d5981a01e80 100644 (file)
@@ -76,7 +76,7 @@ import {
 } from "@mdi/light-js";
 import Mousetrap from "mousetrap";
 import { useToast } from "primevue/usetoast";
-import { computed, ref, watch } from "vue";
+import { computed, onMounted, ref, watch } from "vue";
 import { useRouter } from "vue-router";
 
 import { createNote, deleteNote, getNote, updateNote } from "../api.js";
@@ -114,11 +114,11 @@ Mousetrap.bind("e", function () {
 
 function init() {
   // Return if we already have the note
-  if (props.title == note.value.title) {
+  if (props.title && props.title == note.value.title) {
     return;
   }
 
-  loadingIndicator.value?.setLoading(); // #CS
+  loadingIndicator.value.setLoading();
   if (props.title) {
     getNote(props.title)
       .then((data) => {
@@ -223,5 +223,6 @@ function noteSaveSuccess() {
   toast.add(getToastOptions("Success", "Note saved successfully."));
 }
 
-watch(() => props.title, init, { immediate: true });
+watch(() => props.title, init);
+onMounted(init);
 </script>
index 93f95ee8ce2b36cb1b72564cfb2b81ed1d06d961..68e948f85fc6d22c1c27793f5853a649e916e192 100644 (file)
@@ -37,7 +37,7 @@
 
 <script setup>
 import { useToast } from "primevue/usetoast";
-import { ref, watch } from "vue";
+import { onMounted, ref, watch } from "vue";
 
 import { mdiMagnify } from "@mdi/js";
 import { getNotes } from "../api.js";
@@ -53,7 +53,7 @@ const results = ref([]);
 const toast = useToast();
 
 function init() {
-  loadingIndicator.value?.setLoading(); // #CS
+  loadingIndicator.value.setLoading();
   getNotes(props.searchTerm)
     .then((data) => {
       results.value = data;
@@ -69,7 +69,8 @@ function init() {
     });
 }
 
-watch(() => props.searchTerm, init, { immediate: true });
+watch(() => props.searchTerm, init);
+onMounted(init);
 </script>
 
 <style>
git clone https://git.99rst.org/PROJECT