} 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";
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) => {
toast.add(getToastOptions("Success", "Note saved successfully."));
}
-watch(() => props.title, init, { immediate: true });
+watch(() => props.title, init);
+onMounted(init);
</script>
<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";
const toast = useToast();
function init() {
- loadingIndicator.value?.setLoading(); // #CS
+ loadingIndicator.value.setLoading();
getNotes(props.searchTerm)
.then((data) => {
results.value = data;
});
}
-watch(() => props.searchTerm, init, { immediate: true });
+watch(() => props.searchTerm, init);
+onMounted(init);
</script>
<style>