Merge pull request #161 from 404-Program-not-found/main

fix: fixed issue #158
This commit is contained in:
Kenny 2022-03-22 07:43:17 -04:00 committed by GitHub
commit 4434a14688
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 6 deletions

View File

@ -42,7 +42,11 @@
>
<div class="scroll-y" style="height: 100%">
<div v-if="search" style="min-width: 180px">
<v-list-item v-for="(item, index) in response" :key="index" class="px-0">
<v-list-item
v-for="(item, index) in response"
:key="index"
class="px-0"
>
<v-btn
text
tile
@ -100,6 +104,7 @@ div {
<script>
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}`);

View File

@ -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();
}
},
},
},
};
</script>