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

This commit is contained in:
Silas 2023-11-25 09:36:28 -05:00
parent 5b97348fb7
commit ad61063c0d
Signed by: silentsilas
GPG Key ID: 4199EFB7DAA34349
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},

View File

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