|
|
@ -1,21 +1,55 @@
|
|
|
|
<script setup lang="ts"></script>
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
|
|
import PromiseResolver from "@/components/PromiseResolver.vue";
|
|
|
|
|
|
|
|
import CurrentlyPlayingCompact from "@/components/CurrentlyPlayingCompact.vue";
|
|
|
|
|
|
|
|
import { onBeforeUnmount, ref } from "vue";
|
|
|
|
|
|
|
|
import { useApi } from "@/Api";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const api = useApi();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const userInfo = ref(api?.getCurrentlyPlaying());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let refreshUserInfo = setInterval(() => {
|
|
|
|
|
|
|
|
userInfo.value = api?.getCurrentlyPlaying();
|
|
|
|
|
|
|
|
}, 10000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
|
|
|
clearInterval(refreshUserInfo);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<h1>Me</h1>
|
|
|
|
<h1>Me</h1>
|
|
|
|
|
|
|
|
<h2>Currently Listening to</h2>
|
|
|
|
|
|
|
|
<PromiseResolver
|
|
|
|
|
|
|
|
:promise="userInfo"
|
|
|
|
|
|
|
|
v-slot="{ data: { currentlyPlaying } }"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<CurrentlyPlayingCompact v-if="currentlyPlaying?.item" :currentlyPlaying="currentlyPlaying" />
|
|
|
|
|
|
|
|
<div v-else class="alert alert-info">
|
|
|
|
|
|
|
|
You are not listening to music.
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</PromiseResolver>
|
|
|
|
|
|
|
|
<h2>Session</h2>
|
|
|
|
<PromiseResolver
|
|
|
|
<PromiseResolver
|
|
|
|
:promise="$api.getSession()"
|
|
|
|
:promise="$api.getSession()"
|
|
|
|
v-slot="slot"
|
|
|
|
|
|
|
|
>
|
|
|
|
>
|
|
|
|
|
|
|
|
<template #default="{ data: { session }, update }">
|
|
|
|
<div class="card">
|
|
|
|
<div class="card">
|
|
|
|
<div class="card-header">
|
|
|
|
<div class="card-header">
|
|
|
|
Your session
|
|
|
|
Your session
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="card-body">
|
|
|
|
<div class="card-body">
|
|
|
|
<p>
|
|
|
|
<b>Host</b>
|
|
|
|
{{ slot }}
|
|
|
|
<div>
|
|
|
|
</p>
|
|
|
|
{{ session.host?.spotify.userId }}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<b>Clients</b>
|
|
|
|
<b>Clients</b>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
|
|
|
<div v-for="client in session.clients" :key="client">
|
|
|
|
|
|
|
|
{{ client.displayName }}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="card-footer">
|
|
|
|
<div class="card-footer">
|
|
|
|
<button
|
|
|
|
<button
|
|
|
@ -32,6 +66,20 @@
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #error="{ error, update }">
|
|
|
|
|
|
|
|
<div v-if="error.response.status === 404">
|
|
|
|
|
|
|
|
<div class="alert alert-info">
|
|
|
|
|
|
|
|
You are not part of a session.
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
|
|
|
@click="$api.createSession().then(() => update($api.getSession()))"
|
|
|
|
|
|
|
|
class="btn btn-success"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
Create Session
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
</PromiseResolver>
|
|
|
|
</PromiseResolver>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|