1
0
mirror of https://github.com/TeamPiped/Piped.git synced 2024-12-14 06:10:28 +05:30

Add keybinds for adding playlist.

Closes #963
This commit is contained in:
Kavin 2022-04-09 08:45:25 +01:00
parent f92857ae9f
commit 77742dbb6e
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD

View File

@ -51,20 +51,37 @@ export default {
return {
playlists: [],
selectedPlaylist: null,
processing: false,
};
},
mounted() {
this.fetchPlaylists();
this.selectedPlaylist = this.getPreferenceString("selectedPlaylist" + this.hashCode(this.apiUrl()));
window.addEventListener("keydown", this.handleKeyDown);
window.blur();
},
unmounted() {
window.removeEventListener("keydown", this.handleKeyDown);
},
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) {
if (!playlistId) {
alert(this.$t("actions.please_select_playlist"));
return;
}
if (this.processing) return;
this.$refs.addButton.disabled = true;
this.processing = true;
this.fetchJson(this.apiUrl() + "/user/playlists/add", null, {
method: "POST",