rewrite search tabbing

This commit is contained in:
geoffrey45
2022-09-04 15:30:23 +03:00
parent 24bfa73ab6
commit b7c158a785
12 changed files with 172 additions and 108 deletions
+6 -3
View File
@@ -1,3 +1,4 @@
import { Routes } from "./../composables/enums";
import { ref, reactive } from "@vue/reactivity";
import { defineStore } from "pinia";
import { AlbumInfo, Artist, Playlist, Track } from "../interfaces";
@@ -13,6 +14,7 @@ import { watch } from "vue";
import useDebouncedRef from "../utils/useDebouncedRef";
import useTabStore from "./tabs";
import useLoaderStore from "./loader";
import { useRoute } from "vue-router";
/**
*
* Scrolls on clicking the loadmore button
@@ -31,6 +33,7 @@ export default defineStore("search", () => {
// @ts-ignore
const query = useDebouncedRef(null, 600);
const { startLoading, stopLoading } = useLoaderStore();
const route = useRoute();
const currentTab = ref("tracks");
const RESULT_COUNT = 6;
@@ -154,7 +157,7 @@ export default defineStore("search", () => {
const tabs = useTabStore();
if (tabs.current !== "search") {
if (route.name !== Routes.search && tabs.current !== "search") {
tabs.switchToSearch();
}
@@ -202,7 +205,7 @@ export default defineStore("search", () => {
}
);
function changeTab(tab: string) {
function switchTab(tab: string) {
currentTab.value = tab;
}
@@ -217,6 +220,6 @@ export default defineStore("search", () => {
loadTracks,
loadAlbums,
loadArtists,
changeTab,
switchTab,
};
});