-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide room name if the room is closed #535
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -435,7 +435,7 @@ defmodule RetWeb.PageController do | |
|
||
hub_meta_tags = | ||
Phoenix.View.render_to_string(RetWeb.PageView, "hub-meta.html", | ||
hub: hub, | ||
hub: hub |> maybe_scrub_room_data(), | ||
scene: hub.scene, | ||
ret_meta: Ret.Meta.get_meta(include_repo: false), | ||
available_integrations_script: {:safe, available_integrations_script |> with_script_tags}, | ||
|
@@ -792,4 +792,19 @@ defmodule RetWeb.PageController do | |
defp with_script_tags(script), do: "<script>#{script}</script>" | ||
|
||
defp module_config(key), do: Application.get_env(:ret, __MODULE__)[key] | ||
|
||
defp maybe_scrub_room_data(hub) do | ||
if hub.entry_mode == :deny do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably more idiomatic, not sure if better.. But you could pattern match on the entry_mode instead of using a conditional. As in: defp maybe_scrub_room_data(%Hub{entry_mode: :deny}) do
|
||
Map.merge(hub, %{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might just return a new struct here instead, we could easily add new fields and then forget to "scrub" them later. |
||
name: "Closed Room", | ||
description: "This room is closed.", | ||
slug: "", | ||
scene: nil, | ||
scene_listing: nil, | ||
user_data: nil | ||
}) | ||
else | ||
hub | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we were trying to "scrub" the scene we are still returning it here.