Skip to content

Commit

Permalink
Merge pull request #392 from BytewaveMLP/activity-page-nsfw-channels
Browse files Browse the repository at this point in the history
List NSFW channels on Activity page when enabled
  • Loading branch information
liamwhite authored Jan 2, 2025
2 parents 9557d66 + 6d8ed2d commit 47fe5d5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/philomena_web/controllers/activity_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ defmodule PhilomenaWeb.ActivityController do

streams =
Channel
|> where([c], c.nsfw == false)
|> where([c], not is_nil(c.last_fetched_at))
|> maybe_show_nsfw_channels(conn.cookies["chan_nsfw"])
|> order_by(desc: :is_live, asc: :title)
|> limit(6)
|> Repo.all()
Expand Down Expand Up @@ -142,6 +142,9 @@ defmodule PhilomenaWeb.ActivityController do
)
end

defp maybe_show_nsfw_channels(query, "true"), do: query
defp maybe_show_nsfw_channels(query, _falsy), do: where(query, [c], c.nsfw == false)

defp multi_search(images, top_scoring, comments, nil) do
responses =
Search.msearch_records(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
/ => image_tag 'no_avatar_original.svg', width: 32, height: 32, alt: "#{channel.title}'s logo'", class: 'channel-strip__image'
= @channel.title || @channel.short_name
.flex__fixed.flex__right
= if @channel.nsfw do
span title="NSFW"
' 🔞
'
= if @channel.is_live do
span.channel-strip__state.label.label--narrow.label--success
' LIVE NOW
Expand Down

0 comments on commit 47fe5d5

Please sign in to comment.