diff --git a/NUXT/layouts/default.vue b/NUXT/layouts/default.vue index 1c7441c..2446356 100644 --- a/NUXT/layouts/default.vue +++ b/NUXT/layouts/default.vue @@ -42,7 +42,11 @@ >
- + import { App as CapacitorApp } from "@capacitor/app"; import { mapState } from "vuex"; +import constants from "../plugins/constants"; export default { data: () => ({ search: false, @@ -154,6 +159,11 @@ export default { searchBtn(text) { const query = text; + this.$logger( + constants.LOGGER_NAMES.search, + "Query: " + query + " this.search: " + this.search + ); + if (this.search === true) { if (query) { this.$router.push(`/search?q=${query}`); diff --git a/NUXT/pages/search.vue b/NUXT/pages/search.vue index 0b69f19..1c915c7 100644 --- a/NUXT/pages/search.vue +++ b/NUXT/pages/search.vue @@ -46,11 +46,27 @@ export default { }; }, mounted() { - const searchQuestion = this.$route.query.q; - const vm = this; - this.$youtube.search(searchQuestion, (data) => { - vm.videos = data; - }); + getSearch(); + }, + methods: { + getSearch() { + const searchQuestion = this.$route.query.q; + const vm = this; + this.$youtube.search(searchQuestion, (data) => { + vm.videos = data; + }); + }, + }, + watch: { + // Watches for new searches while the current search page is active. + $route: { + deep: true, + handler(newSearch, oldSearch) { + if (newSearch.query.q != oldSearch.query.q) { + this.getSearch(); + } + }, + }, }, };