grover isnt mounted with thread id anymore
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user