mirror of
https://codeberg.org/JasterV/intisync.ex.git
synced 2026-04-26 18:10:07 +00:00
make credo happy
This commit is contained in:
parent
d1a093d8cc
commit
fd7849dfb7
7 changed files with 26 additions and 8 deletions
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Intisync.Puid do
|
||||
@doc """
|
||||
@moduledoc """
|
||||
Generate Probably unique identifiers
|
||||
"""
|
||||
use Puid
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
defmodule Intisync.SessionPubSub do
|
||||
@moduledoc """
|
||||
Provides function to publish/subscribe to IntiSync.PubSub topics
|
||||
"""
|
||||
|
||||
def broadcast!(session_id, topic, event, payload) do
|
||||
topic = "#{topic}:#{event}:#{session_id}"
|
||||
payload = %{payload: payload, topic: topic}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
defmodule Intisync.SessionServer do
|
||||
alias Intisync.SessionPubSub
|
||||
@moduledoc """
|
||||
Contains the business logic of a session.
|
||||
It is the source of truth of the session state.
|
||||
"""
|
||||
use GenServer
|
||||
|
||||
alias Intisync.SessionPubSub
|
||||
|
||||
def init(session_id) do
|
||||
{:ok,
|
||||
%{
|
||||
|
|
@ -47,8 +52,8 @@ defmodule Intisync.SessionServer do
|
|||
GenServer.call(pid, {:get_devices})
|
||||
end
|
||||
|
||||
def is_full?(pid) do
|
||||
GenServer.call(pid, {:is_full?})
|
||||
def full?(pid) do
|
||||
GenServer.call(pid, {:full?})
|
||||
end
|
||||
|
||||
def handle_call({:get_id}, _from, state) do
|
||||
|
|
@ -59,10 +64,10 @@ defmodule Intisync.SessionServer do
|
|||
{:reply, state.devices, state}
|
||||
end
|
||||
|
||||
def handle_call({:is_full?}, _from, state) do
|
||||
is_full? = state.remote_connection_status == :connected
|
||||
def handle_call({:full?}, _from, state) do
|
||||
full? = state.remote_connection_status == :connected
|
||||
|
||||
{:reply, is_full?, state}
|
||||
{:reply, full?, state}
|
||||
end
|
||||
|
||||
def handle_call({:device_connected, index, device}, _from, state) do
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
defmodule Intisync.SessionsSupervisor do
|
||||
@moduledoc """
|
||||
DynamicSupervisor responsible to manage SessionServers
|
||||
"""
|
||||
use DynamicSupervisor
|
||||
|
||||
alias Intisync.SessionServer
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
defmodule IntisyncWeb.LiveViewMonitor do
|
||||
@moduledoc """
|
||||
Monitors LiveView processes and calls their `unmount` functions when they die
|
||||
"""
|
||||
use GenServer
|
||||
|
||||
def start_link(init_arg) do
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
defmodule IntisyncWeb.DeviceCardComponent do
|
||||
@moduledoc """
|
||||
Renders a device card
|
||||
"""
|
||||
use Phoenix.Component
|
||||
import IntisyncWeb.CoreComponents
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ defmodule IntisyncWeb.RemoteLive do
|
|||
{:error, :not_found}
|
||||
|
||||
pid ->
|
||||
if SessionServer.is_full?(pid) do
|
||||
if SessionServer.full?(pid) do
|
||||
{:error, :unauthorized}
|
||||
else
|
||||
{:ok, pid}
|
||||
|
|
|
|||
Loading…
Reference in a new issue