grover isnt mounted with thread id anymore

This commit is contained in:
2022-08-03 13:42:44 +02:00
parent 9594a9bc04
commit 4bd3634abb
3 changed files with 11 additions and 13 deletions

View File

@ -4,10 +4,10 @@ defmodule SomethingErlang.Grover do
alias SomethingErlang.AwfulApi
require Logger
def mount(user, thread_id) do
DynamicSupervisor.start_child(
def mount(user) do
{:ok, _pid} = DynamicSupervisor.start_child(
SomethingErlang.Supervisor.Grovers,
{__MODULE__, [self(), user, thread_id]}
{__MODULE__, [self(), user]}
)
end
@ -15,24 +15,22 @@ defmodule SomethingErlang.Grover do
GenServer.call(via(self()), {:show_thread, thread_id, page_number})
end
def start_link([lv_pid, user, thread_id]) do
def start_link([lv_pid, user]) do
GenServer.start_link(
__MODULE__,
[lv_pid, user, thread_id],
[lv_pid, user],
name: via(lv_pid))
end
@impl true
def init([pid, user, thread_id]) do
def init([pid, user]) do
%{bbuserid: userid, bbpassword: userhash} = user
initial_state = %{
lv_pid: pid,
thread_id: thread_id,
page_number: 1,
user: %{id: userid, hash: userhash}
}
Logger.debug "init #{userid} #{thread_id}"
Logger.debug "init #{userid} #{inspect(pid)}"
Process.monitor(pid)
{:ok, initial_state}
end
@ -40,7 +38,7 @@ defmodule SomethingErlang.Grover do
@impl true
def handle_call({:show_thread, thread_id, page_number}, _from, state) do
thread = AwfulApi.parsed_thread(thread_id, page_number, state.user)
{:reply, thread, %{state | page_number: page_number}}
{:reply, thread, state}
end
@impl true

View File

@ -7,8 +7,8 @@ defmodule SomethingErlangWeb.ThreadLive.Show do
require Logger
@impl true
def mount(%{"id" => id} = _params, _session, socket) do
Grover.mount(socket.assigns.current_user, id)
def mount(_params, _session, socket) do
Grover.mount(socket.assigns.current_user)
{:ok, socket}
end