mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-11-10 10:18:23 +00:00
parent
f92857ae9f
commit
77742dbb6e
@ -51,20 +51,37 @@ export default {
|
|||||||
return {
|
return {
|
||||||
playlists: [],
|
playlists: [],
|
||||||
selectedPlaylist: null,
|
selectedPlaylist: null,
|
||||||
|
processing: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.fetchPlaylists();
|
this.fetchPlaylists();
|
||||||
this.selectedPlaylist = this.getPreferenceString("selectedPlaylist" + this.hashCode(this.apiUrl()));
|
this.selectedPlaylist = this.getPreferenceString("selectedPlaylist" + this.hashCode(this.apiUrl()));
|
||||||
|
window.addEventListener("keydown", this.handleKeyDown);
|
||||||
|
window.blur();
|
||||||
|
},
|
||||||
|
unmounted() {
|
||||||
|
window.removeEventListener("keydown", this.handleKeyDown);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleKeyDown(event) {
|
||||||
|
if (event.code === "Escape") {
|
||||||
|
this.$emit("close");
|
||||||
|
} else if (event.code === "Enter") {
|
||||||
|
this.handleClick(this.selectedPlaylist);
|
||||||
|
} else return;
|
||||||
|
event.preventDefault();
|
||||||
|
},
|
||||||
handleClick(playlistId) {
|
handleClick(playlistId) {
|
||||||
if (!playlistId) {
|
if (!playlistId) {
|
||||||
alert(this.$t("actions.please_select_playlist"));
|
alert(this.$t("actions.please_select_playlist"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.processing) return;
|
||||||
|
|
||||||
this.$refs.addButton.disabled = true;
|
this.$refs.addButton.disabled = true;
|
||||||
|
this.processing = true;
|
||||||
|
|
||||||
this.fetchJson(this.apiUrl() + "/user/playlists/add", null, {
|
this.fetchJson(this.apiUrl() + "/user/playlists/add", null, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
Loading…
Reference in New Issue
Block a user