fix bug where document genserver hasn't started by the time the client connects to its channel
This commit is contained in:
parent
5b97348fb7
commit
ad61063c0d
|
@ -1,5 +1,8 @@
|
|||
defmodule PoexWeb.PadChannel do
|
||||
use Phoenix.Channel
|
||||
alias Poex.Pads.DocumentDynamicSupervisor
|
||||
alias Poex.Repo
|
||||
alias Poex.Pads.Document
|
||||
alias Poex.Pads.DocumentServer
|
||||
|
||||
@moduledoc """
|
||||
|
@ -11,6 +14,8 @@ defmodule PoexWeb.PadChannel do
|
|||
end
|
||||
|
||||
def join("pad:" <> document_id, _params, socket) do
|
||||
document = Repo.get!(Document, document_id)
|
||||
DocumentDynamicSupervisor.start_document_server(document)
|
||||
contents = DocumentServer.get_contents(document_id)
|
||||
|
||||
{:ok, %{uuid: socket.assigns.uuid, contents: contents},
|
||||
|
|
|
@ -24,6 +24,7 @@ defmodule PoexWeb.PadLive do
|
|||
contents: contents
|
||||
} = document = Repo.get!(Document, id)
|
||||
|
||||
# TODO: do we need to start the server here?
|
||||
DocumentDynamicSupervisor.start_document_server(document)
|
||||
|
||||
# init editor and assigns with latest state from doc
|
||||
|
|
Loading…
Reference in New Issue