fix bug where document genserver hasn't started by the time the client connects to its channel

This commit is contained in:
2023-11-25 09:36:28 -05:00
parent 5b97348fb7
commit ad61063c0d
2 changed files with 6 additions and 0 deletions

View File

@@ -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},