Add support for local playlists

This commit is contained in:
Bnyro
2023-06-15 19:18:47 +02:00
parent 2e64c4f003
commit 37d6423e08
6 changed files with 167 additions and 15 deletions

View File

@@ -86,14 +86,11 @@ export default {
mounted() {
const playlistId = this.$route.query.list;
if (this.authenticated && playlistId?.length == 36)
this.fetchJson(this.authApiUrl() + "/user/playlists", null, {
headers: {
Authorization: this.getAuthToken(),
},
}).then(json => {
this.getPlaylists().then(json => {
if (json.error) alert(json.error);
else if (json.some(playlist => playlist.id === playlistId)) this.admin = true;
});
else if (playlistId.startsWith("local")) this.admin = true;
this.isPlaylistBookmarked();
},
activated() {
@@ -106,6 +103,11 @@ export default {
},
methods: {
async fetchPlaylist() {
const playlistId = this.$route.query.list;
if (playlistId.startsWith("local")) {
return this.getPlaylist(playlistId);
}
return await await this.fetchJson(this.authApiUrl() + "/playlists/" + this.$route.query.list);
},
async getPlaylistData() {

View File

@@ -238,8 +238,7 @@ export default {
cursorRequest.onsuccess = e => {
const cursor = e.target.result;
if (cursor) {
const bookmark = cursor.value;
this.bookmarks.push(bookmark);
this.bookmarks.push(cursor.value);
cursor.continue();
}
};

View File

@@ -107,7 +107,7 @@
>
<font-awesome-icon icon="headphones" />
</router-link>
<button v-if="authenticated" :title="$t('actions.add_to_playlist')" @click="showModal = !showModal">
<button :title="$t('actions.add_to_playlist')" @click="showModal = !showModal">
<font-awesome-icon icon="circle-plus" />
</button>
<button
@@ -127,7 +127,7 @@
<PlaylistAddModal
v-if="showModal"
:video-id="item.url.substr(-11)"
video-info="item"
:video-info="item"
@close="showModal = !showModal"
/>
</div>

View File

@@ -94,7 +94,7 @@
/>
<div class="flex flex-wrap gap-1 ml-auto">
<!-- Subscribe Button -->
<button class="btn flex items-center" v-if="authenticated" @click="showModal = !showModal">
<button class="btn flex items-center" @click="showModal = !showModal">
{{ $t("actions.add_to_playlist") }}<font-awesome-icon class="ml-1" icon="circle-plus" />
</button>
<button
@@ -112,7 +112,7 @@
title="RSS feed"
role="button"
v-if="video.uploaderUrl"
:href="`${apiUrl()}/feed/unauthenticated/rss?channels=${video.uploaderUrl.split('/')[2]}`"
:href="`${apiUrl()}/fss?channels=${video.uploaderUrl.split('/')[2]}`"
target="_blank"
class="btn flex items-center"
>
@@ -494,7 +494,7 @@ export default {
},
async fetchSubscribedStatus() {
if (!this.channelId) return;
if (!this.authenticated) {
if ({
this.subscribed = this.isSubscribedLocally(this.channelId);
return;
}
@@ -531,7 +531,7 @@ export default {
});
},
subscribeHandler() {
if (this.authenticated) {
if {
this.fetchJson(this.authApiUrl() + (this.subscribed ? "/unsubscribe" : "/subscribe"), null, {
method: "POST",
body: JSON.stringify({