mirror of
https://github.com/tcsenpai/swingmusic.git
synced 2025-07-29 06:02:06 +00:00
fix loadmore counter not resetting
- store load more counter in search store
This commit is contained in:
parent
75123f5384
commit
191ac0bc7b
@ -21,8 +21,6 @@ body {
|
|||||||
image-rendering: -webkit-optimize-contrast;
|
image-rendering: -webkit-optimize-contrast;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.heading {
|
.heading {
|
||||||
font-size: 2rem;
|
font-size: 2rem;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@ -87,9 +85,10 @@ a {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.gsearch-input {
|
#gsearch-input {
|
||||||
grid-area: search-input;
|
grid-area: search-input;
|
||||||
border-left: solid 1px $gray3;
|
// border-left: solid 1px $gray3;
|
||||||
|
// border-bottom: 1px solid $gray3;
|
||||||
}
|
}
|
||||||
|
|
||||||
.topnav {
|
.topnav {
|
||||||
|
@ -20,10 +20,9 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import Search from "./Search/Main.vue";
|
import Search from "./Search/Main.vue";
|
||||||
import UpNext from "./Queue.vue";
|
import UpNext from "./Queue.vue";
|
||||||
import Main from "./Home/Main.vue";
|
import DashBoard from "./Home/Main.vue";
|
||||||
import useTabStore from "../../stores/tabs";
|
import useTabStore from "../../stores/tabs";
|
||||||
// import Search from "./Searchh.vue";
|
|
||||||
const DashBoard = Main;
|
|
||||||
const tabs = useTabStore();
|
const tabs = useTabStore();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -31,7 +30,7 @@ const tabs = useTabStore();
|
|||||||
.r-sidebar {
|
.r-sidebar {
|
||||||
width: 29em;
|
width: 29em;
|
||||||
background-color: rgba(4, 12, 34, 0.103);
|
background-color: rgba(4, 12, 34, 0.103);
|
||||||
padding: 0 0 0 $small;
|
padding: 0 $small;
|
||||||
|
|
||||||
@include phone-only {
|
@include phone-only {
|
||||||
display: none;
|
display: none;
|
||||||
|
@ -33,7 +33,6 @@ function playThis(track: Track) {
|
|||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.up-next {
|
.up-next {
|
||||||
padding: $small $small 0 0;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<div class="grid">
|
<div class="grid">
|
||||||
<AlbumCard
|
<AlbumCard
|
||||||
v-for="album in search.albums.value"
|
v-for="album in search.albums.value"
|
||||||
:key="album.image"
|
:key="`${album.artist}-${album.title}`"
|
||||||
:album="album"
|
:album="album"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -18,11 +18,9 @@ import useSearchStore from "../../../stores/search";
|
|||||||
|
|
||||||
const search = useSearchStore();
|
const search = useSearchStore();
|
||||||
|
|
||||||
let counter = 0;
|
|
||||||
|
|
||||||
function loadMore() {
|
function loadMore() {
|
||||||
counter += 6;
|
search.updateLoadCounter("albums", 6);
|
||||||
search.loadAlbums(counter);
|
search.loadAlbums(search.loadCounter.albums);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
v-for="artist in search.artists.value"
|
v-for="artist in search.artists.value"
|
||||||
:key="artist.image"
|
:key="artist.image"
|
||||||
:artist="artist"
|
:artist="artist"
|
||||||
|
:alt="true"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<LoadMore v-if="search.artists.more" @loadMore="loadMore" />
|
<LoadMore v-if="search.artists.more" @loadMore="loadMore" />
|
||||||
@ -17,11 +18,9 @@ import LoadMore from "./LoadMore.vue";
|
|||||||
import useSearchStore from "../../../stores/search";
|
import useSearchStore from "../../../stores/search";
|
||||||
const search = useSearchStore();
|
const search = useSearchStore();
|
||||||
|
|
||||||
let counter = 0;
|
|
||||||
|
|
||||||
function loadMore() {
|
function loadMore() {
|
||||||
counter += 6;
|
search.updateLoadCounter("artists", 6);
|
||||||
search.loadArtists(counter);
|
search.loadArtists(search.loadCounter.artists);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -31,7 +30,6 @@ function loadMore() {
|
|||||||
padding: $small;
|
padding: $small;
|
||||||
margin-bottom: $small;
|
margin-bottom: $small;
|
||||||
|
|
||||||
|
|
||||||
.xartist {
|
.xartist {
|
||||||
background-color: $gray;
|
background-color: $gray;
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,12 @@ import useQStore from "../../../stores/queue";
|
|||||||
import { Track } from "../../../interfaces";
|
import { Track } from "../../../interfaces";
|
||||||
import useSearchStore from "../../../stores/search";
|
import useSearchStore from "../../../stores/search";
|
||||||
|
|
||||||
let counter = 0;
|
|
||||||
const queue = useQStore();
|
const queue = useQStore();
|
||||||
const search = useSearchStore();
|
const search = useSearchStore();
|
||||||
|
|
||||||
function loadMore() {
|
function loadMore() {
|
||||||
counter += 5;
|
search.updateLoadCounter("tracks", 5);
|
||||||
search.loadTracks(counter);
|
search.loadTracks(search.loadCounter.tracks);
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateQueue(track: Track) {
|
function updateQueue(track: Track) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="xartist" :style="{ backgroundColor: `#${color}` }">
|
<div class="xartist" :class="{ _is_on_sidebar: alt }">
|
||||||
<div
|
<div
|
||||||
class="artist-image image border-sm"
|
class="artist-image image border-sm"
|
||||||
:style="{ backgroundImage: `url('${imguri + artist.image}')` }"
|
:style="{ backgroundImage: `url('${imguri + artist.image}')` }"
|
||||||
@ -11,15 +11,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { Artist } from "@/interfaces";
|
||||||
import { paths } from "../../config";
|
import { paths } from "../../config";
|
||||||
|
|
||||||
const imguri = paths.images.artist;
|
const imguri = paths.images.artist;
|
||||||
|
|
||||||
defineProps<{
|
defineProps<{
|
||||||
artist: any;
|
artist: Artist;
|
||||||
color?: string;
|
alt?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
@ -65,4 +65,8 @@ defineProps<{
|
|||||||
max-width: 7rem;
|
max-width: 7rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
._is_on_sidebar {
|
||||||
|
background-color: $gray4 !important;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -4,7 +4,6 @@ import useFStore from "@/stores/pages/folder";
|
|||||||
import usePStore from "@/stores/pages/playlist";
|
import usePStore from "@/stores/pages/playlist";
|
||||||
import useQStore from "@/stores/queue";
|
import useQStore from "@/stores/queue";
|
||||||
|
|
||||||
|
|
||||||
const queue = useQStore;
|
const queue = useQStore;
|
||||||
const folder = useFStore;
|
const folder = useFStore;
|
||||||
const album = useAStore;
|
const album = useAStore;
|
||||||
|
@ -29,6 +29,11 @@ function scrollOnLoad() {
|
|||||||
export default defineStore("search", () => {
|
export default defineStore("search", () => {
|
||||||
const query = useDebouncedRef(null, 600);
|
const query = useDebouncedRef(null, 600);
|
||||||
const currentTab = ref("tracks");
|
const currentTab = ref("tracks");
|
||||||
|
const loadCounter = reactive({
|
||||||
|
tracks: 0,
|
||||||
|
albums: 0,
|
||||||
|
artists: 0,
|
||||||
|
});
|
||||||
|
|
||||||
const tracks = reactive({
|
const tracks = reactive({
|
||||||
query: "",
|
query: "",
|
||||||
@ -118,9 +123,27 @@ export default defineStore("search", () => {
|
|||||||
.then(() => scrollOnLoad());
|
.then(() => scrollOnLoad());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateLoadCounter(type: string, value: number) {
|
||||||
|
switch (type) {
|
||||||
|
case "tracks":
|
||||||
|
loadCounter.tracks += value;
|
||||||
|
break;
|
||||||
|
case "albums":
|
||||||
|
loadCounter.albums += value;
|
||||||
|
break;
|
||||||
|
case "artists":
|
||||||
|
loadCounter.artists += value;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => query.value,
|
() => query.value,
|
||||||
(newQuery) => {
|
(newQuery) => {
|
||||||
|
for (const key in loadCounter) {
|
||||||
|
loadCounter[key] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
const tabs = useTabStore();
|
const tabs = useTabStore();
|
||||||
|
|
||||||
if (tabs.current !== "search") {
|
if (tabs.current !== "search") {
|
||||||
@ -183,6 +206,8 @@ export default defineStore("search", () => {
|
|||||||
artists,
|
artists,
|
||||||
query,
|
query,
|
||||||
currentTab,
|
currentTab,
|
||||||
|
loadCounter,
|
||||||
|
updateLoadCounter,
|
||||||
loadTracks,
|
loadTracks,
|
||||||
loadAlbums,
|
loadAlbums,
|
||||||
loadArtists,
|
loadArtists,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user