From eafdb082e17bf7a29bedf18e1ef02a8ec713d2c3 Mon Sep 17 00:00:00 2001 From: Miguel Michelson Martinez Date: Mon, 27 Jun 2022 17:54:14 -0400 Subject: [PATCH 1/2] Follows (#12) * readme * follows menu resource * integrate pagination * menu tweak * track list components & reposts * private preview + embed + reposts --- README.md | 15 +- lib/rauversion/accounts.ex | 23 ++- lib/rauversion/accounts/user.ex | 13 +- lib/rauversion/blob_utils.ex | 2 +- lib/rauversion/repo.ex | 2 + lib/rauversion/reposts.ex | 4 + lib/rauversion/services/peaks_generator.ex | 19 +- lib/rauversion/tracks.ex | 13 +- lib/rauversion/tracks/track_metadata.ex | 6 +- lib/rauversion/user_follows.ex | 130 +++++++++++++ lib/rauversion/user_follows/user_follow.ex | 21 +++ .../active_storage/blobs/proxy_controller.ex | 4 +- .../active_storage/disk_controller.ex | 4 +- .../representations/redirect_controller.ex | 2 - .../controllers/embed_controller.ex | 19 +- .../controllers/user_settings_controller.ex | 2 +- .../live/follows_live/components/user_list.ex | 32 ++++ lib/rauversion_web/live/follows_live/index.ex | 71 ++++++++ .../live/follows_live/index.html.heex | 75 ++++++++ lib/rauversion_web/live/live_helpers.ex | 5 +- .../profile_live/components/menu_component.ex | 2 +- .../components/share_track_component.ex | 8 +- .../components/stats_component.ex | 8 +- .../components/trending_component.ex | 2 +- .../components/user_suggestions_component.ex | 8 +- lib/rauversion_web/live/profile_live/index.ex | 63 ++++++- .../live/profile_live/index.html.heex | 21 ++- .../track_live/components/sharer_component.ex | 2 +- .../track_live/components/track_component.ex | 88 ++++++++- .../components/track_list_component.ex | 4 +- lib/rauversion_web/live/track_live/index.ex | 2 +- lib/rauversion_web/live/track_live/new.ex | 2 +- lib/rauversion_web/live/track_live/show.ex | 13 ++ lib/rauversion_web/router.ex | 6 + .../templates/page/index.html.heex | 2 +- .../templates/profile/show.html.heex | 171 ------------------ mix.exs | 1 + mix.lock | 2 + .../20220627045506_create_user_follows.exs | 15 ++ ...iel-schludi-mbGxz7pt0jM-unsplash-sqr-s.png | Bin 0 -> 664694 bytes ...aniel-schludi-mbGxz7pt0jM-unsplash-sqr.png | Bin 0 -> 680452 bytes .../sai-harish-kjNwiW4BjJE-unsplash-sqr.png | Bin 0 -> 317151 bytes .../sai-harish-kjNwiW4BjJE-unsplash.jpg | Bin 0 -> 378134 bytes test/rauversion/user_follows_test.exs | 118 ++++++++++++ .../support/fixtures/user_follows_fixtures.ex | 20 ++ 45 files changed, 779 insertions(+), 241 deletions(-) create mode 100644 lib/rauversion/user_follows.ex create mode 100644 lib/rauversion/user_follows/user_follow.ex create mode 100644 lib/rauversion_web/live/follows_live/components/user_list.ex create mode 100644 lib/rauversion_web/live/follows_live/index.ex create mode 100644 lib/rauversion_web/live/follows_live/index.html.heex delete mode 100644 lib/rauversion_web/templates/profile/show.html.heex create mode 100644 priv/repo/migrations/20220627045506_create_user_follows.exs create mode 100644 priv/static/images/daniel-schludi-mbGxz7pt0jM-unsplash-sqr-s.png create mode 100644 priv/static/images/daniel-schludi-mbGxz7pt0jM-unsplash-sqr.png create mode 100644 priv/static/images/sai-harish-kjNwiW4BjJE-unsplash-sqr.png create mode 100644 priv/static/images/sai-harish-kjNwiW4BjJE-unsplash.jpg create mode 100644 test/rauversion/user_follows_test.exs create mode 100644 test/support/fixtures/user_follows_fixtures.ex diff --git a/README.md b/README.md index 57447d9a..9611956c 100644 --- a/README.md +++ b/README.md @@ -31,17 +31,21 @@ Now you can visit [`localhost:4000`](http://localhost:4000) from your browser. - [x] File uploads Avatar - [x] User auth - [x] Tracks +- [x] Add metadata form step +- [x] Embed at /embed/:track_id +- [x] Embed at /embed/:track_id/private with signed_id - [ ] Paginate profile tracks /:username - [ ] Paginate /tracks -- [ ] Filter public/private tracks (where: private: true) -- [ ] Add metadata form step** +- [ ] Listening history +- [x] Filter public/private tracks (where: private: true) - [ ] Give feedback on upload preprosessing - [ ] A logo for rauversion -- [ ] Reposts +- [x] Reposts - [ ] Albums - [ ] Playlists - [ ] Likes -- [ ] Followers / Followings +- [x] Private preview on show +- [x] Followers / Followings - [ ] Telemetry for dashboard - [ ] Centralized player, fixed (bottom) across navigation @@ -78,4 +82,7 @@ Photo by Dan-Cristian Pădureț on Unsplash Photo by Gritt Zheng on Unsplash + +Photo by Sai Harish on Unsplash + diff --git a/lib/rauversion/accounts.ex b/lib/rauversion/accounts.ex index babffb33..c601d41e 100644 --- a/lib/rauversion/accounts.ex +++ b/lib/rauversion/accounts.ex @@ -19,7 +19,7 @@ defmodule Rauversion.Accounts do {:ok, result} end - def broadcast_change({:error, result}, event) do + def broadcast_change({:error, result}, _event) do {:error, result} end @@ -27,6 +27,19 @@ defmodule Rauversion.Accounts do User |> limit(^limit) |> Repo.all() end + def tracks_count(user) do + user + |> Ecto.assoc(:tracks) + |> Repo.aggregate(:count, :id) + end + + def unfollowed_users(user) do + from(u in User, + left_join: m in assoc(u, :followings), + where: is_nil(m.id) + ) + end + ## Database getters @doc """ @@ -156,14 +169,10 @@ defmodule Rauversion.Accounts do # a = Rauversion.Accounts.get_user_by_username("michelson") |> Rauversion.Repo.preload(:avatar_blob) case user do nil -> - Rauversion.BlobUtils.fallback_image( - "/images/dan-cristian-padure-XKCH37dHt7w-unsplash.jpg" - ) + Rauversion.BlobUtils.fallback_image("/images/sai-harish-kjNwiW4BjJE-unsplash-sqr.png") %{avatar_blob: nil} -> - Rauversion.BlobUtils.fallback_image( - "/images/dan-cristian-padure-XKCH37dHt7w-unsplash.jpg" - ) + Rauversion.BlobUtils.fallback_image("/images/sai-harish-kjNwiW4BjJE-unsplash-sqr.png") %{avatar_blob: %ActiveStorage.Blob{} = avatar_blob} -> avatar_blob |> ActiveStorage.url() diff --git a/lib/rauversion/accounts/user.ex b/lib/rauversion/accounts/user.ex index 1211ef7b..b0cfb8df 100644 --- a/lib/rauversion/accounts/user.ex +++ b/lib/rauversion/accounts/user.ex @@ -15,6 +15,8 @@ defmodule Rauversion.Accounts.User do field :confirmed_at, :naive_datetime has_many :tracks, Rauversion.Tracks.Track + has_many :followings, Rauversion.UserFollows.UserFollow, foreign_key: :following_id + has_many :followers, Rauversion.UserFollows.UserFollow, foreign_key: :follower_id has_one(:avatar_attachment, ActiveStorage.Attachment, where: [record_type: "User", name: "avatar"], @@ -30,22 +32,21 @@ defmodule Rauversion.Accounts.User do "User" end - def profile_changeset(user, attrs, opts \\ []) do + def profile_changeset(user, attrs, _opts \\ []) do user |> validate_contact_fields(attrs) |> process_avatar(attrs) end def changeset(user, attrs, opts \\ []) do - user = - user - |> validate_contact_fields(attrs) - |> registration_changeset(attrs, opts) + user + |> validate_contact_fields(attrs) + |> registration_changeset(attrs, opts) end def process_avatar(user, attrs) do case attrs do - %{"avatar" => avatar} -> + %{"avatar" => _avatar} -> blob = ActiveStorage.Blob.create_and_upload!( %ActiveStorage.Blob{}, diff --git a/lib/rauversion/blob_utils.ex b/lib/rauversion/blob_utils.ex index 454fcb58..aafc385b 100644 --- a/lib/rauversion/blob_utils.ex +++ b/lib/rauversion/blob_utils.ex @@ -2,7 +2,7 @@ defmodule Rauversion.BlobUtils do def fallback_image(url \\ nil) do RauversionWeb.Router.Helpers.static_path( RauversionWeb.Endpoint, - url || "/images/daniel-schludi-mbGxz7pt0jM-unsplash.jpg" + url || "/images/daniel-schludi-mbGxz7pt0jM-unsplash-sqr-s.png" ) end diff --git a/lib/rauversion/repo.ex b/lib/rauversion/repo.ex index 3d477e98..d941e478 100644 --- a/lib/rauversion/repo.ex +++ b/lib/rauversion/repo.ex @@ -2,4 +2,6 @@ defmodule Rauversion.Repo do use Ecto.Repo, otp_app: :rauversion, adapter: Ecto.Adapters.Postgres + + use Scrivener, page_size: 10 end diff --git a/lib/rauversion/reposts.ex b/lib/rauversion/reposts.ex index 5c8b0f0f..50633806 100644 --- a/lib/rauversion/reposts.ex +++ b/lib/rauversion/reposts.ex @@ -37,6 +37,10 @@ defmodule Rauversion.Reposts do """ def get_repost!(id), do: Repo.get!(Repost, id) + def get_repost_by_user_and_track(user_id, track_id) do + Repost |> where(user_id: ^user_id) |> where(track_id: ^track_id) |> Repo.one() + end + @doc """ Creates a repost. diff --git a/lib/rauversion/services/peaks_generator.ex b/lib/rauversion/services/peaks_generator.ex index e4a14243..5663f340 100644 --- a/lib/rauversion/services/peaks_generator.ex +++ b/lib/rauversion/services/peaks_generator.ex @@ -21,7 +21,7 @@ defmodule Rauversion.Services.PeaksGenerator do ]) # |> normalize - frames = Jason.decode!(output)["data"] + Jason.decode!(output)["data"] # audiowaveform -i ~/Desktop/patio/STE-098.mp3 @@ -40,15 +40,14 @@ defmodule Rauversion.Services.PeaksGenerator do IO.inspect(cmd) output = :os.cmd(cmd) - frames = - Jason.decode!(output)["frames"] - |> Enum.map(fn x -> - case get_in(x, ["tags", "lavfi.astats.Overall.Peak_level"]) |> Float.parse() do - {f, _} -> f - _ -> nil - end - end) - |> normalize + Jason.decode!(output)["frames"] + |> Enum.map(fn x -> + case get_in(x, ["tags", "lavfi.astats.Overall.Peak_level"]) |> Float.parse() do + {f, _} -> f + _ -> nil + end + end) + |> normalize end def desired_pixels_per_second(desired_pixels, duration) do diff --git a/lib/rauversion/tracks.ex b/lib/rauversion/tracks.ex index 51f3887c..71a8739f 100644 --- a/lib/rauversion/tracks.ex +++ b/lib/rauversion/tracks.ex @@ -19,10 +19,21 @@ defmodule Rauversion.Tracks do {:ok, result} end - def broadcast_change({:error, result}, event) do + def broadcast_change({:error, result}, _event) do {:error, result} end + def signed_id(track) do + token = Phoenix.Token.sign(RauversionWeb.Endpoint, "user auth", track.id) + end + + def find_by_signed_id!(token) do + case Phoenix.Token.verify(RauversionWeb.Endpoint, "user auth", token, max_age: 86400) do + {:ok, track_id} -> get_track!(track_id) + _ -> nil + end + end + @doc """ Returns the list of tracks. diff --git a/lib/rauversion/tracks/track_metadata.ex b/lib/rauversion/tracks/track_metadata.ex index 817ad83d..2e5000fa 100644 --- a/lib/rauversion/tracks/track_metadata.ex +++ b/lib/rauversion/tracks/track_metadata.ex @@ -82,7 +82,7 @@ defmodule Rauversion.Tracks.TrackMetadata do # |> validate_prescence_url_if(["frame", "link", "url"]) end - def form_definitions(type = "metadata") do + def form_definitions(_type = "metadata") do [ %{ name: :genre, @@ -230,7 +230,7 @@ defmodule Rauversion.Tracks.TrackMetadata do ] end - def form_definitions(type = "common") do + def form_definitions(_type = "common") do [ %{ name: :attribution, @@ -269,7 +269,7 @@ defmodule Rauversion.Tracks.TrackMetadata do # TODO: move this to another store / module def genres do - names = [ + [ "Alternative Rock", "Ambient", "Classical", diff --git a/lib/rauversion/user_follows.ex b/lib/rauversion/user_follows.ex new file mode 100644 index 00000000..d9c0fc34 --- /dev/null +++ b/lib/rauversion/user_follows.ex @@ -0,0 +1,130 @@ +defmodule Rauversion.UserFollows do + @moduledoc """ + The UserFollows context. + """ + + import Ecto.Query, warn: false + alias Rauversion.Repo + + alias Rauversion.UserFollows.UserFollow + + @doc """ + Returns the list of user_follows. + + ## Examples + + iex> list_user_follows() + [%UserFollow{}, ...] + + """ + def list_user_follows do + Repo.all(UserFollow) + end + + def followers_list_for(user) do + UserFollow + |> where(following_id: ^user.id) + |> Repo.all() + |> Repo.preload([:following, :follower]) + end + + def followers_for(user) do + UserFollow + |> where(following_id: ^user.id) + |> Repo.aggregate(:count, :id) + end + + def followings_list_for(user) do + UserFollow + |> where(follower_id: ^user.id) + |> Repo.all() + |> Repo.preload([:following, :follower]) + end + + def followings_for(user) do + UserFollow + |> where(follower_id: ^user.id) + |> Repo.aggregate(:count, :id) + end + + @doc """ + Gets a single user_follow. + + Raises `Ecto.NoResultsError` if the User follow does not exist. + + ## Examples + + iex> get_user_follow!(123) + %UserFollow{} + + iex> get_user_follow!(456) + ** (Ecto.NoResultsError) + + """ + def get_user_follow!(id), do: Repo.get!(UserFollow, id) + + @doc """ + Creates a user_follow. + + ## Examples + + iex> create_user_follow(%{field: value}) + {:ok, %UserFollow{}} + + iex> create_user_follow(%{field: bad_value}) + {:error, %Ecto.Changeset{}} + + """ + def create_user_follow(attrs \\ %{}) do + %UserFollow{} + |> UserFollow.changeset(attrs) + |> Repo.insert() + end + + @doc """ + Updates a user_follow. + + ## Examples + + iex> update_user_follow(user_follow, %{field: new_value}) + {:ok, %UserFollow{}} + + iex> update_user_follow(user_follow, %{field: bad_value}) + {:error, %Ecto.Changeset{}} + + """ + def update_user_follow(%UserFollow{} = user_follow, attrs) do + user_follow + |> UserFollow.changeset(attrs) + |> Repo.update() + end + + @doc """ + Deletes a user_follow. + + ## Examples + + iex> delete_user_follow(user_follow) + {:ok, %UserFollow{}} + + iex> delete_user_follow(user_follow) + {:error, %Ecto.Changeset{}} + + """ + def delete_user_follow(%UserFollow{} = user_follow) do + Repo.delete(user_follow) + end + + @doc """ + Returns an `%Ecto.Changeset{}` for tracking user_follow changes. + + ## Examples + + iex> change_user_follow(user_follow) + %Ecto.Changeset{data: %UserFollow{}} + + """ + def change_user_follow(%UserFollow{} = user_follow, attrs \\ %{}) do + UserFollow.changeset(user_follow, attrs) + end +end diff --git a/lib/rauversion/user_follows/user_follow.ex b/lib/rauversion/user_follows/user_follow.ex new file mode 100644 index 00000000..03004f8d --- /dev/null +++ b/lib/rauversion/user_follows/user_follow.ex @@ -0,0 +1,21 @@ +defmodule Rauversion.UserFollows.UserFollow do + use Ecto.Schema + import Ecto.Changeset + + schema "user_follows" do + # field :follower_id, :id + # field :following_id, :id + + belongs_to :follower, Rauversion.Accounts.User, foreign_key: :follower_id + belongs_to :following, Rauversion.Accounts.User, foreign_key: :following_id + + timestamps() + end + + @doc false + def changeset(user_follow, attrs) do + user_follow + |> cast(attrs, [:follower_id, :following_id]) + |> validate_required([:follower_id, :following_id]) + end +end diff --git a/lib/rauversion_web/active_storage/blobs/proxy_controller.ex b/lib/rauversion_web/active_storage/blobs/proxy_controller.ex index 4af39c54..c643edae 100644 --- a/lib/rauversion_web/active_storage/blobs/proxy_controller.ex +++ b/lib/rauversion_web/active_storage/blobs/proxy_controller.ex @@ -25,7 +25,7 @@ defmodule RauversionWeb.ActiveStorage.Blobs.ProxyController do def show(conn, %{"signed_id" => signed_id}) do case conn |> handle_action(signed_id) do - %{assigns: %{blob: blob}} = conn -> + %{assigns: %{blob: _blob}} = conn -> handle_range_request(conn) _ -> @@ -50,7 +50,7 @@ defmodule RauversionWeb.ActiveStorage.Blobs.ProxyController do range = {range_start, conn.assigns.blob.byte_size} send_range(conn, range) - {range_start, range_end} = range -> + {_range_start, _range_end} = range -> send_range(conn, range) ranges when is_list(ranges) -> diff --git a/lib/rauversion_web/active_storage/disk_controller.ex b/lib/rauversion_web/active_storage/disk_controller.ex index 70971934..a57142be 100644 --- a/lib/rauversion_web/active_storage/disk_controller.ex +++ b/lib/rauversion_web/active_storage/disk_controller.ex @@ -10,7 +10,7 @@ defmodule RauversionWeb.ActiveStorage.DiskController do action_fallback RauversionWeb.FallbackController - def show(conn, %{"encoded_key" => encoded_key, "filename" => filename}) do + def show(conn, %{"encoded_key" => encoded_key, "filename" => _filename}) do case decode_verified_key(encoded_key) do {:ok, verified} -> res = Jason.decode!(verified) @@ -44,7 +44,7 @@ defmodule RauversionWeb.ActiveStorage.DiskController do ActiveStorage.verifier().verified(params[:encoded_token], purpose: :blob_token) end - def acceptable_content?(token) do + def acceptable_content?(_token) do # token[:content_type] == request.content_mime_type && # token[:content_length] == request.content_length end diff --git a/lib/rauversion_web/active_storage/representations/redirect_controller.ex b/lib/rauversion_web/active_storage/representations/redirect_controller.ex index 1542f3d2..7b56f5e6 100644 --- a/lib/rauversion_web/active_storage/representations/redirect_controller.ex +++ b/lib/rauversion_web/active_storage/representations/redirect_controller.ex @@ -46,8 +46,6 @@ defmodule RauversionWeb.ActiveStorage.Representations.RedirectController do def set_representation(conn, params) do try do - conn - representation = conn.assigns.blob.__struct__.representation(conn.assigns.blob, params["variation_key"]) diff --git a/lib/rauversion_web/controllers/embed_controller.ex b/lib/rauversion_web/controllers/embed_controller.ex index 89504a10..ee9b5f8f 100644 --- a/lib/rauversion_web/controllers/embed_controller.ex +++ b/lib/rauversion_web/controllers/embed_controller.ex @@ -9,6 +9,23 @@ defmodule RauversionWeb.EmbedController do |> assign(:track, track) |> delete_resp_header("x-frame-options") - render(conn, "show.html") + case track do + nil -> conn |> send_resp(404, "This track is private or not found") + _ -> render(conn, "show.html") + end + end + + def private(conn, %{"track_id" => track_id}) do + track = Rauversion.Tracks.find_by_signed_id!(track_id) + + conn = + conn + |> assign(:track, track) + |> delete_resp_header("x-frame-options") + + case track do + nil -> conn |> send_resp(404, "This track is private or not found") + _ -> render(conn, "show.html") + end end end diff --git a/lib/rauversion_web/controllers/user_settings_controller.ex b/lib/rauversion_web/controllers/user_settings_controller.ex index 87539c42..f6ff2411 100644 --- a/lib/rauversion_web/controllers/user_settings_controller.ex +++ b/lib/rauversion_web/controllers/user_settings_controller.ex @@ -55,7 +55,7 @@ defmodule RauversionWeb.UserSettingsController do user = conn.assigns.current_user case Accounts.update_user_profile(user, user_params) do - {:ok, user} -> + {:ok, _user} -> conn |> put_flash(:info, "User profile updated successfully.") |> redirect(to: Routes.user_settings_path(conn, :edit)) diff --git a/lib/rauversion_web/live/follows_live/components/user_list.ex b/lib/rauversion_web/live/follows_live/components/user_list.ex new file mode 100644 index 00000000..7a0b1f37 --- /dev/null +++ b/lib/rauversion_web/live/follows_live/components/user_list.ex @@ -0,0 +1,32 @@ +defmodule RauversionWeb.FollowsLive.UserListComponent do + # If you generated an app with mix phx.new --live, + # the line below would be: use MyAppWeb, :live_component + # use Phoenix.LiveComponent + use RauversionWeb, :live_component + + def render( + %{ + collection: collection + } = assigns + ) do + ~H""" +
+

<%= @kind %>

+ +
+ """ + end +end diff --git a/lib/rauversion_web/live/follows_live/index.ex b/lib/rauversion_web/live/follows_live/index.ex new file mode 100644 index 00000000..39195107 --- /dev/null +++ b/lib/rauversion_web/live/follows_live/index.ex @@ -0,0 +1,71 @@ +defmodule RauversionWeb.FollowsLive.Index do + use RauversionWeb, :live_view + on_mount RauversionWeb.UserLiveAuth + + alias Rauversion.Tracks.Track + alias Rauversion.{Repo, Tracks, Accounts, UserFollows} + alias RauversionWeb.TrackLive.Step + + @impl true + def mount(_params, _session, socket) do + # @current_user + + {:ok, socket} + end + + @impl true + def handle_params(params, _url, socket) do + case apply_action(socket, socket.assigns.live_action, params) do + {:ok, reply} -> + {:noreply, reply} + + {:err, err} -> + {:noreply, err} + + any -> + {:noreply, any} + end + end + + defp apply_action(socket, :followers, %{"username" => username}) do + user = Accounts.get_user_by_username(username) + follows = UserFollows.followers_list_for(user) + + socket + |> assign(:page_title, "Listing Tracks") + |> assign(:follow_kind, :follower) + |> assign(:profile, user) + |> assign(:collection, follows) + end + + defp apply_action(socket, :followings, %{"username" => username}) do + user = Accounts.get_user_by_username(username) + follows = UserFollows.followings_list_for(user) + + socket + |> assign(:page_title, "Listing Tracks") + |> assign(:profile, user) + |> assign(:follow_kind, :following) + |> assign(:collection, follows) + end + + defp apply_action(socket, :likes, %{"username" => username}) do + user = Accounts.get_user_by_username(username) + + socket + |> assign(:page_title, "Listing Tracks") + |> assign(:profile, user) + |> assign(:follow_kind, :likes) + |> assign(:collection, []) + end + + defp apply_action(socket, :comments, %{"username" => username}) do + user = Accounts.get_user_by_username(username) + + socket + |> assign(:page_title, "Listing Tracks") + |> assign(:profile, user) + |> assign(:follow_kind, :comments) + |> assign(:collection, []) + end +end diff --git a/lib/rauversion_web/live/follows_live/index.html.heex b/lib/rauversion_web/live/follows_live/index.html.heex new file mode 100644 index 00000000..1afcfbae --- /dev/null +++ b/lib/rauversion_web/live/follows_live/index.html.heex @@ -0,0 +1,75 @@ +
+
+ + + +
+ +
+
+
+
+ <%= img_tag(Rauversion.Accounts.avatar_url(@profile), class: "h-16 w-16 rounded-full") %> + +
+
+ +
+

<%= @profile.username %>

+
+
+
+ <%= live_redirect "Go to profile", to: Routes.profile_index_path(@socket, :index, @profile.username) , class: "inline-flex items-center justify-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-orange-600 hover:bg-orange-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-100 focus:ring-orange-500" %> +
+
+ + + + +
+ + <%= case @follow_kind do + :follower -> + live_component( + RauversionWeb.FollowsLive.UserListComponent, + id: "user-list-#{@profile.id}", + track: "track", + profile: @profile, + kind: @follow_kind, + collection: @collection + ) + :following -> + live_component( + RauversionWeb.FollowsLive.UserListComponent, + id: "user-list-#{@profile.id}", + track: "track", + profile: @profile, + kind: @follow_kind, + collection: @collection + ) + :likes -> "LIKES SOON!" + :comments -> "COMMENTS SOON!" + _ -> "nothing to display!" + + end %> + +
+
diff --git a/lib/rauversion_web/live/live_helpers.ex b/lib/rauversion_web/live/live_helpers.ex index 351e96b1..1d8ee145 100644 --- a/lib/rauversion_web/live/live_helpers.ex +++ b/lib/rauversion_web/live/live_helpers.ex @@ -84,9 +84,8 @@ defmodule RauversionWeb.LiveHelpers do if session["user_token"] do user = Rauversion.Accounts.get_user_by_session_token(session["user_token"]) - socket = - socket - |> assign(:current_user, user) + socket + |> assign(:current_user, user) else socket end diff --git a/lib/rauversion_web/live/profile_live/components/menu_component.ex b/lib/rauversion_web/live/profile_live/components/menu_component.ex index 89e6fa46..06799651 100644 --- a/lib/rauversion_web/live/profile_live/components/menu_component.ex +++ b/lib/rauversion_web/live/profile_live/components/menu_component.ex @@ -4,7 +4,7 @@ defmodule RauversionWeb.ProfileLive.MenuComponent do # use Phoenix.LiveComponent use RauversionWeb, :live_component - def render(%{data: data} = assigns) do + def render(%{data: _data} = assigns) do ~H"""
diff --git a/lib/rauversion_web/live/profile_live/components/share_track_component.ex b/lib/rauversion_web/live/profile_live/components/share_track_component.ex index 0d1da288..3e3a4310 100644 --- a/lib/rauversion_web/live/profile_live/components/share_track_component.ex +++ b/lib/rauversion_web/live/profile_live/components/share_track_component.ex @@ -31,7 +31,7 @@ defmodule RauversionWeb.ProfileLive.ShareTrackComponent do
@@ -102,6 +102,12 @@ defmodule RauversionWeb.ProfileLive.ShareTrackComponent do value={Routes.embed_url(@socket, :show, track)} class="shadow-sm focus:ring-orange-500 focus:border-orange-500 block w-full sm:text-sm border-gray-300 rounded-md" /> + + +