+
![Background Image]()
diff --git a/frontend/src/components/SongItem.vue b/frontend/src/components/SongItem.vue
index a52ae8c..c79bf12 100644
--- a/frontend/src/components/SongItem.vue
+++ b/frontend/src/components/SongItem.vue
@@ -13,7 +13,6 @@ const audioStore = useAudio();
function updateSong() {
let updated = props.song;
- console.log("updating song:", updated)
audioStore.setSong(updated)
}
@@ -21,19 +20,19 @@ function updateSong() {
-
-
![]()
+
- {{ props.song?.name ?? 'Title' }}
+ {{ props.song?.name ? props.song?.name : 'Unknown Title' }}
- {{ props.song?.artist ?? 'Artist' }}
+ {{ props.song?.artist ? props.song.artist : 'Unknown Artist' }}
- {{ Math.floor(props.song?.length ?? 0 / 60000) }}:{{ Math.floor((props.song?.length ?? 0 /
+ {{ Math.floor(props.song?.length / 60000 ?? 0) }}:{{ Math.floor((props.song?.length ?? 0 /
1000)
% 60).toString().padStart(2, '0') }}
diff --git a/frontend/src/composables/useAudio.ts b/frontend/src/composables/useAudio.ts
index 8f76e0b..7cbd4d1 100644
--- a/frontend/src/composables/useAudio.ts
+++ b/frontend/src/composables/useAudio.ts
@@ -22,6 +22,7 @@ function createAudio() {
repeat: ref(false),
activeSongs: ref
([]),
currentSong: ref(null),
+ recentlyPlayed: ref(new Map()),
}
function saveToLocalStorage(key: string, data: any) {
@@ -34,11 +35,17 @@ function createAudio() {
}
function setSong(song: Song | null) {
- console.log(song)
if (!song) return
state.currentSong.value = song
- saveToLocalStorage('lastPlayedSong', song)
+ const map = state.recentlyPlayed.value;
+
+ saveToLocalStorage('lastPlayedSong', song)
+ if (map.has(song.hash)) {
+ map.delete(song.hash);
+ }
+ map.set(song.hash, song);
+
audioElement.pause()
audioElement.src = song.url
audioElement.addEventListener(
@@ -66,6 +73,11 @@ function toggleNext() {
if (!state.activeSongs.value || !state.currentSong.value) return;
const songs = state.activeSongs.value;
+
+ if(state.shuffle.value){
+ setSong(songs[Math.floor(Math.random() * songs.length)]);
+ }
+
const currentHash = state.currentSong.value.hash;
const currentIndex = songs.findIndex(song => song.hash === currentHash);
@@ -99,8 +111,13 @@ function togglePrevious() {
if (state.repeat.value) {
audioElement.currentTime = 0
audioElement.play()
+ return
}
+
+ toggleNext();
}
+
+
}
function formatTime(seconds: number): string {
@@ -109,11 +126,8 @@ function togglePrevious() {
return `${min}:${sec}`
}
- function updateTime() {
- const slider = document.getElementById('audio-slider') as HTMLInputElement
- if (slider) {
- audioElement.currentTime = (Number(slider.value) / 100) * audioElement.duration
- }
+ function updateTime(value: number) {
+ if (value) audioElement.currentTime = (Number(value) / 100) * audioElement.duration
}
async function loadInitialSong() {
diff --git a/frontend/src/views/CollectionView.vue b/frontend/src/views/CollectionView.vue
index 1f69dbb..81bc387 100644
--- a/frontend/src/views/CollectionView.vue
+++ b/frontend/src/views/CollectionView.vue
@@ -19,9 +19,7 @@ const fetchCollections = async () => {
isLoading.value = true;
const response = await api.musicBackendCollections(offset.value, limit.value);
- console.log(response.data.songs.length)
let songs = mapApiToCollectionPreview(response.data.songs)
- console.log(songs)
collections.value = [...collections.value, ...songs];
offset.value += limit.value;
@@ -48,7 +46,7 @@ onMounted(async () => {
-
+
diff --git a/frontend/src/views/FavouritView.vue b/frontend/src/views/FavouritView.vue
index ae3e6f0..f186117 100644
--- a/frontend/src/views/FavouritView.vue
+++ b/frontend/src/views/FavouritView.vue
@@ -3,7 +3,7 @@ import SongItem from '../components/SongItem.vue'
-
+
Coming Soon...
diff --git a/frontend/src/views/HistoryView.vue b/frontend/src/views/HistoryView.vue
new file mode 100644
index 0000000..55e9df6
--- /dev/null
+++ b/frontend/src/views/HistoryView.vue
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/frontend/src/views/MeView.vue b/frontend/src/views/MeView.vue
index f769838..b954117 100644
--- a/frontend/src/views/MeView.vue
+++ b/frontend/src/views/MeView.vue
@@ -32,8 +32,6 @@ function save(bg: string | null, main: string | null, info: string | null, borde
localStorage.setItem('actionColor', main ?? actionColor.value);
localStorage.setItem('infoColor', info ?? infoColor.value);
localStorage.setItem('borderColor', border ?? borderColor.value);
-
- console.log("bg", bgColor.value, "action:", actionColor.value, "info", infoColor.value, "border", borderColor.value)
}
async function getMe() {
@@ -44,12 +42,10 @@ async function getMe() {
console.log("redirect detected");
}
- console.log(data)
if (data.id === null || data.id === undefined || Object.keys(data).length === 0) {
return
}
- console.log("active user: ", data.name)
userStore.setUser(data);
userStore.baseUrl.value(data.endpoint);
@@ -86,7 +82,7 @@ function reset() {
-
+
@@ -128,10 +124,9 @@ function reset() {
class="appearance-none w-8 h-8 border-2 p-0 overflow-hidden cursor-pointer">
-
@@ -139,14 +134,14 @@ function reset() {
class="border rounded-lg p-0.5" @click="save('#000000', '#5e2d8f', '#57db5d', '#b3002d')">Choose
-
+
@@ -155,7 +150,7 @@ function reset() {
-
+
@@ -164,7 +159,7 @@ function reset() {
-
+
@@ -173,7 +168,7 @@ function reset() {
-
+
diff --git a/frontend/src/views/MenuView.vue b/frontend/src/views/MenuView.vue
index 22e409c..ade0ba5 100644
--- a/frontend/src/views/MenuView.vue
+++ b/frontend/src/views/MenuView.vue
@@ -10,10 +10,10 @@ function isActive(path: string) {
-
+
-
diff --git a/frontend/src/views/RecentView.vue b/frontend/src/views/RecentView.vue
index f8c873c..01841b2 100644
--- a/frontend/src/views/RecentView.vue
+++ b/frontend/src/views/RecentView.vue
@@ -2,7 +2,7 @@
import SongItem from '../components/SongItem.vue'
import { type Song, type CollectionPreview, mapApiToSongs } from '../script/types'
-import { ref, onMounted } from 'vue'
+import { ref, onMounted, nextTick } from 'vue'
import { useRoute } from 'vue-router';
import { useAudio } from '@/composables/useAudio';
import { useUser } from '@/composables/useUser';
@@ -16,6 +16,7 @@ const api = musicApi()
const songs = ref([]);
const name = ref('name');
+const containerRef = ref(null);
const limit = ref(100);
const offset = ref(0);
@@ -46,7 +47,9 @@ const fetchRecent = async () => {
onMounted(async () => {
await fetchRecent();
- const container = document.querySelector('.song-container');
+ await nextTick();
+
+ const container = containerRef.value;
if (container) {
container.addEventListener('scroll', async () => {
const scrollTop = container.scrollTop;
@@ -64,11 +67,10 @@ onMounted(async () => {
-
-
-
-
+