Skip to content

Commit

Permalink
connected search input to api, full window search still missing
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowLp174 committed Jan 20, 2024
1 parent 6e9064a commit 34ad871
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
13 changes: 13 additions & 0 deletions dashboard/static/js/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,17 @@ export default class API {
});
});
}
play(query) {
return new Promise((res) => {
const notification = this.notifications.addInfo("Playlist", "Adding to playlist. Watch the current progress in the revolt channel (WIP)", 5000)
this.post("/dashboard/queue", { action: "add", query: query }).then(async d => {
notification.description = d.message;
res(d.message);
}).catch(e => {
notification.removeNotif();
this.notifications.addError("Playlist Error", e.message, 7000);
res(e.message);
});
});
}
}
6 changes: 5 additions & 1 deletion dashboard/static/js/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,11 @@ class Player extends HTMLElement {
// TODO: implement loop control

const search = document.createElement("search-input");
search.addEventListener("result", (e) => console.log(e.detail))
search.addEventListener("result", ({ detail: data }) => {
console.log(data);
//if (!data.url) return;
this.api.play(data.raw);
});
// TODO: implement full window search
cCon.append(search);

Expand Down
1 change: 1 addition & 0 deletions dashboard/static/js/SearchInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class SearchInput extends HTMLElement {
async #keyUp(e) {
if (e.code === "Enter") {
e.preventDefault();
if (e.target.value === "" && e.target.value !== "0") return;
this.#dispatchSearch(e.target.value);
this.#reset();
return;
Expand Down

0 comments on commit 34ad871

Please sign in to comment.