Skip to content

Commit

Permalink
Merge pull request #379 from geekingfrog/fix-compiler-warnings
Browse files Browse the repository at this point in the history
Fix compiler warnings
  • Loading branch information
L-e-x-o-n authored Jul 28, 2024
2 parents 7f521fe + 867b60e commit 0e8a7ae
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 39 deletions.
2 changes: 1 addition & 1 deletion lib/teiserver/helpers/styling_helpers.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ defmodule Teiserver.Helper.StylingHelper do

@spec icon(atom) :: String.t()
def icon(nil), do: nil
def icon(nil, _), do: nil
def icon(atom), do: icon(atom, "solid")

@spec icon(atom, String.t()) :: String.t()
def icon(nil, _), do: nil
def icon(:report, fa_type), do: "fa-#{fa_type} fa-signal"
def icon(:up, fa_type), do: "fa-#{fa_type} fa-level-up"
def icon(:back, fa_type), do: "fa-#{fa_type} fa-arrow-left"
Expand Down
2 changes: 0 additions & 2 deletions lib/teiserver/moderation/queries/report_group_queries.ex
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ defmodule Teiserver.Moderation.ReportGroupQueries do
where: fragment("? ~* ?", reports.type, ^kind)
end

defp _where(query, :has_reports_of_kind, nil), do: query

@spec do_order_by(Ecto.Query.t(), list | nil) :: Ecto.Query.t()
defp do_order_by(query, nil), do: query

Expand Down
3 changes: 1 addition & 2 deletions lib/teiserver_web/controllers/admin/match_controller.ex
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
defmodule TeiserverWeb.Admin.MatchController do
use TeiserverWeb, :controller

alias Teiserver.{Battle, Game, Account, Telemetry}
alias Teiserver.Battle.{MatchLib, BalanceLib}
alias Teiserver.{Battle, Game, Account}
import Teiserver.Helper.StringHelper, only: [get_hash_id: 1]
require Logger

Expand Down
62 changes: 31 additions & 31 deletions lib/teiserver_web/live/account/profile/overview.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ defmodule TeiserverWeb.Account.ProfileLive.Overview do
|> assign(:page_title, "#{user.name} - Achievements")
end

@impl true
def handle_info(%{channel: "teiserver_client_messages:" <> _, event: :connected}, socket) do
user_id = socket.assigns.user.id

Expand All @@ -84,6 +85,20 @@ defmodule TeiserverWeb.Account.ProfileLive.Overview do
end

@impl true
def handle_event("join", _params, %{assigns: assigns} = socket) do
current_user_id = assigns.current_user.id
lobby_id = assigns.client.lobby_id

with :ok <- client_connected(current_user_id),
:ok <- server_allows_join(lobby_id, current_user_id),
:ok <- join_lobby(lobby_id, current_user_id) do
{:noreply, put_flash(socket, :success, "Lobby joined")}
else
{:error, reason} ->
{:noreply, put_flash(socket, :warning, reason)}
end
end

def handle_event(
"follow-user",
_event,
Expand Down Expand Up @@ -269,37 +284,6 @@ defmodule TeiserverWeb.Account.ProfileLive.Overview do
{:noreply, socket}
end

def get_relationships_and_permissions(%{assigns: %{current_user: nil}} = socket) do
socket
|> assign(:relationship, [])
|> assign(:friendship, [])
|> assign(:friendship_request, [])
|> assign(:profile_permissions, [])
end

def get_relationships_and_permissions(%{assigns: %{user: nil}} = socket) do
socket
|> assign(:relationship, [])
|> assign(:friendship, [])
|> assign(:friendship_request, [])
|> assign(:profile_permissions, [])
end

def handle_event("join", _params, %{assigns: assigns} = socket) do
user_id = assigns.user.id
current_user_id = assigns.current_user.id
lobby_id = assigns.client.lobby_id

with :ok <- client_connected(current_user_id),
:ok <- server_allows_join(lobby_id, current_user_id),
:ok <- join_lobby(lobby_id, current_user_id) do
{:noreply, put_flash(socket, :success, "Lobby joined")}
else
{:error, reason} ->
{:noreply, put_flash(socket, :warning, reason)}
end
end

defp client_connected(user_id) do
client = Account.get_client_by_id(user_id)

Expand All @@ -325,6 +309,22 @@ defmodule TeiserverWeb.Account.ProfileLive.Overview do
end
end

def get_relationships_and_permissions(%{assigns: %{current_user: nil}} = socket) do
socket
|> assign(:relationship, [])
|> assign(:friendship, [])
|> assign(:friendship_request, [])
|> assign(:profile_permissions, [])
end

def get_relationships_and_permissions(%{assigns: %{user: nil}} = socket) do
socket
|> assign(:relationship, [])
|> assign(:friendship, [])
|> assign(:friendship_request, [])
|> assign(:profile_permissions, [])
end

def get_relationships_and_permissions(
%{assigns: %{current_user: current_user, user: user}} = socket
)
Expand Down
4 changes: 1 addition & 3 deletions lib/teiserver_web/templates/admin/user/smurf_list.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,7 @@ is_moderator = allow?(@conn, "Moderator") %>
</tr>

<%= for user <- @users do %>
<% user_stats = @stats_map[user.id]
games_allied = @games_allied[user.id]
games_vs = @games_vs[user.id] %>
<% user_stats = @stats_map[user.id] %>

<tr>
<td style={"background-color: #{user.colour}; color: #FFF;"} width="22">
Expand Down

0 comments on commit 0e8a7ae

Please sign in to comment.