From 7ea456d49f364b5ff438157d5dd6ba2dc5443578 Mon Sep 17 00:00:00 2001 From: Chris McCord Date: Fri, 18 Mar 2022 08:57:13 -0400 Subject: [PATCH] WIP --- assets/js/app.js | 23 ++-- lib/live_beats/media_library.ex | 8 ++ lib/live_beats_web/live/live_helpers.ex | 5 +- .../live/profile_live/song_entry_component.ex | 118 +++++++++++++++++- .../profile_live/upload_form_component.ex | 1 + .../upload_form_component.html.heex | 8 +- mix.exs | 3 +- mix.lock | 4 +- priv/repo/seeds.exs | 19 +-- 9 files changed, 155 insertions(+), 34 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 4432fb5..9460b4b 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -1,6 +1,6 @@ import "phoenix_html" import {Socket} from "phoenix" -import {LiveSocket} from "phoenix_live_view" +import {LiveSocket} from "./phoenix_live_view" import topbar from "../vendor/topbar" let nowSeconds = () => Math.round(Date.now() / 1000) @@ -13,6 +13,10 @@ let execJS = (selector, attr) => { let Hooks = {} +Hooks.Test = { + mounted(){ console.log("mounted test") }, + destroyed(){ console.log("destroyed test") } +} Hooks.Flash = { mounted(){ let hide = () => liveSocket.execJS(this.el, this.el.getAttribute("phx-click")) @@ -184,12 +188,12 @@ Hooks.AudioPlayer = { Hooks.Ping = { mounted(){ - this.handleEvent("pong", () => { - let rtt = Date.now() - this.nowMs - this.el.innerText = `ping: ${rtt}ms` - this.timer = setTimeout(() => this.ping(rtt), 1000) - }) - this.ping(null) + // this.handleEvent("pong", () => { + // let rtt = Date.now() - this.nowMs + // this.el.innerText = `ping: ${rtt}ms` + // this.timer = setTimeout(() => this.ping(rtt), 1000) + // }) + // this.ping(null) }, reconnected(){ clearTimeout(this.timer) @@ -303,7 +307,10 @@ window.addEventListener("phx:page-loading-stop", info => topbar.hide()) // Accessible routing window.addEventListener("phx:page-loading-stop", e => routeUpdated(e.detail)) -window.addEventListener("js:exec", e => e.target[e.detail.call](...e.detail.args)) +window.addEventListener("js:exec", e => { + console.log(e.detail) + e.target[e.detail.call](...e.detail.args) +}) window.addEventListener("js:focus", e => { let parent = document.querySelector(e.detail.parent) if(parent && isVisible(parent)){ e.target.focus() } diff --git a/lib/live_beats/media_library.ex b/lib/live_beats/media_library.ex index b8f9193..01097c6 100644 --- a/lib/live_beats/media_library.ex +++ b/lib/live_beats/media_library.ex @@ -240,6 +240,14 @@ defmodule LiveBeats.MediaLibrary do Repo.replica().all(Genre, order_by: [asc: :title]) end + def suggest_genres(like) do + Repo.replica().all(from g in Genre, where: ilike(g.title, ^"%#{like}%")) + end + + def get_genre!(id) do + Repo.replica().get!(Genre, id) + end + def list_profile_songs(%Profile{} = profile, limit \\ 100) do from(s in Song, where: s.user_id == ^profile.user_id, limit: ^limit) |> order_by_playlist(:asc) diff --git a/lib/live_beats_web/live/live_helpers.ex b/lib/live_beats_web/live/live_helpers.ex index 2dc8eb5..54176c7 100644 --- a/lib/live_beats_web/live/live_helpers.ex +++ b/lib/live_beats_web/live/live_helpers.ex @@ -348,7 +348,10 @@ defmodule LiveBeatsWeb.LiveHelpers do |> assign_rest(~w(id show patch navigate on_cancel on_confirm title confirm cancel)a) ~H""" -
+
<.focus_wrap id={"#{@id}-focus-wrap"} content={"##{@id}-container"}>