Skip to content

Commit

Permalink
Follows fix (rauversion#16)
Browse files Browse the repository at this point in the history
* like icon solid on like present

* follows fix, playlist add fix

* readme notes

* dashboard on prod
  • Loading branch information
michelson authored Jul 9, 2022
1 parent 77068e7 commit 6d33326
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 20 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ Now you can visit [`localhost:4000`](http://localhost:4000) from your browser.
- [x] Reposts
- [ ] Albums
- [ ] Playlists
- [ ] add to playlist select playlist / modal first tab
- [ ] sort songs on playlist
- [ ] A WYSIWYG editor for Markdown for Track/Playlist description
- [x] Likes
- [x] Private preview on show
- [x] Followers / Followings
Expand Down
2 changes: 1 addition & 1 deletion lib/rauversion_web/live/playlist_live/form_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ defmodule RauversionWeb.PlaylistLive.FormComponent do
})

playlists =
Rauversion.Playlists.list_playlists_by_user(assigns.current_user)
Rauversion.Playlists.list_playlists_by_user(track.user, assigns.current_user)
|> Rauversion.Repo.all()

{:ok,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ defmodule RauversionWeb.ProfileLive.UserSuggestionComponent do
# use Phoenix.LiveComponent
use RauversionWeb, :live_component

alias Rauversion.{Accounts, Tracks, UserFollows, Repo, Reposts, Playlists}
alias Rauversion.{Accounts, UserFollows, Repo}

@impl true
def update(assigns, socket) do
{
:ok,
Expand All @@ -16,8 +17,8 @@ defmodule RauversionWeb.ProfileLive.UserSuggestionComponent do
end

defp who_to_follow() do
Rauversion.Accounts.unfollowed_users(@profile)
|> Rauversion.Repo.paginate(page: 1, page_size: 5)
Accounts.unfollowed_users(@profile)
|> Repo.paginate(page: 1, page_size: 5)

# |> Rauversion.Repo.preload(:avatar_blob)
end
Expand All @@ -29,7 +30,7 @@ defmodule RauversionWeb.ProfileLive.UserSuggestionComponent do
following_id: id
})

{:noreply, socket}
{:noreply, socket |> assign(:collection, who_to_follow())}
end

def render(%{collection: collection} = assigns) do
Expand All @@ -48,7 +49,7 @@ defmodule RauversionWeb.ProfileLive.UserSuggestionComponent do
<div class="flex-shrink-0">
<%= img_tag(
Rauversion.Accounts.avatar_url(item),
Accounts.avatar_url(item),
class: "h-8 w-8 rounded-full") %>
</div>
Expand Down
17 changes: 10 additions & 7 deletions lib/rauversion_web/live/profile_live/index.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,16 @@
/>
</div>

<section aria-labelledby="who-to-follow-heading">
<.live_component
module={RauversionWeb.ProfileLive.UserSuggestionComponent}
id={"track-#{@profile.id}-user-suggestion"}
profile={@profile}
/>
</section>
<%= if assigns[:current_user] do %>
<section aria-labelledby="who-to-follow-heading">
<.live_component
module={RauversionWeb.ProfileLive.UserSuggestionComponent}
id={"track-#{@profile.id}-user-suggestion"}
profile={@profile}
current_user={@current_user}
/>
</section>
<% end %>

<section aria-labelledby="trending-heading">
<.live_component
Expand Down
15 changes: 11 additions & 4 deletions lib/rauversion_web/live/track_live/components/track_component.ex
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,20 @@ defmodule RauversionWeb.TrackLive.TrackComponent do
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z" clip-rule="evenodd" />
</svg>
<span>Repost <% #= if @repost do @repost.id else "no" end %></span>
<span>Repost</span>
<% end %>
<%= link to: "#", phx_click: "like-track", phx_target: @myself, phx_value_id: track.id,
class: like_class.class do %>
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z" />
</svg>
<%= if @like do %>
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M3.172 5.172a4 4 0 015.656 0L10 6.343l1.172-1.171a4 4 0 115.656 5.656L10 17.657l-6.828-6.829a4 4 0 010-5.656z" clip-rule="evenodd" />
</svg>
<% else %>
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z" />
</svg>
<% end %>
<span>Like</span>
<% end %>
Expand Down Expand Up @@ -249,6 +255,7 @@ defmodule RauversionWeb.TrackLive.TrackComponent do
<span>Delete</span>
<% end %>
<% end %>
<% #= link_to "Show this track", track, class: "inline-flex items-center px-2.5 py-1.5 border border-gray-300 shadow-sm text-xs font-medium rounded text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %>
<% #= link_to 'Edit this track', edit_track_path(track), class: "inline-flex items-center px-2.5 py-1.5 border border-gray-300 shadow-sm text-xs font-medium rounded text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" %>
</div>
Expand Down
3 changes: 2 additions & 1 deletion lib/rauversion_web/live/track_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ defmodule RauversionWeb.TrackLive.Index do

socket =
socket
|> assign(:tracks, list_tracks)
|> assign(:tracks, [])

{:ok, socket}
end
Expand Down Expand Up @@ -59,6 +59,7 @@ defmodule RauversionWeb.TrackLive.Index do

defp apply_action(socket, :index, _params) do
socket
|> assign(:tracks, list_tracks)
|> assign(:page_title, "Listing Tracks")
|> assign(:track, nil)
end
Expand Down
9 changes: 8 additions & 1 deletion lib/rauversion_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ defmodule RauversionWeb.Router do

import RauversionWeb.UserAuth

import Plug.BasicAuth

pipeline :bauth do
plug :basic_auth, username: "rau", password: "raurocks"
end

pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
Expand Down Expand Up @@ -51,11 +57,12 @@ defmodule RauversionWeb.Router do
# If your application does not have an admins-only section yet,
# you can use Plug.BasicAuth to set up some basic authentication
# as long as you are also using SSL (which you should anyway).
if Mix.env() in [:dev, :test] do
if Mix.env() in [:dev, :test, :prod] do
import Phoenix.LiveDashboard.Router

scope "/" do
pipe_through :browser
pipe_through :bauth
live_dashboard "/dashboard", metrics: RauversionWeb.Telemetry, ecto_repos: [Rauversion.Repo]
end
end
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ defmodule Rauversion.MixProject do
def application do
[
mod: {Rauversion.Application, []},
extra_applications: [:logger, :runtime_tools]
extra_applications: [:logger, :runtime_tools, :os_mon]
]
end

Expand Down

0 comments on commit 6d33326

Please sign in to comment.