Skip to content

Commit

Permalink
Relax constraint on session sync to automated id
Browse files Browse the repository at this point in the history
  • Loading branch information
ks0m1c_dharma committed Sep 21, 2024
1 parent 08effb6 commit 82e4ae0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/vyasa_web/components/source_content/reading_content.ex
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,15 @@ defmodule VyasaWeb.Content.ReadingContent do

# Helper function that syncs and mutates draft table
defp mutate_draft_table(%{assigns: %{draft_table: %Vyasa.Sangh.Comment{} = dt, marks: marks}} = socket) do
IO.inspect(dt, label: "DROFT")
{:ok, com} = Vyasa.Sangh.update_comment(dt, %{marks: marks})
socket
|> assign(:draft_table, com)
end

# when session hasnt been initialised
defp mutate_draft_table(socket) do
socket
end
# currently naive hd lookup can be filter based on active toggle,
# tree like comments can be used to store nested collapsible topics (personal mark collection e.g.)
# currently marks merged in and swapped out probably can be singular data structure
Expand Down
4 changes: 2 additions & 2 deletions lib/vyasa_web/live/display_manager/display_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ defmodule VyasaWeb.DisplayManager.DisplayLive do
}
end

defp sync_session(%{assigns: %{session: %Session{name: name, sangh: %{id: _sangh_id}} = sess}} = socket) when is_binary(name) do
defp sync_session(%{assigns: %{session: %Session{id: id, sangh: %{id: _sangh_id}} = sess}} = socket) when is_binary(id) do
# currently needs name prerequisite to save
socket
|> push_event("initSession", sess)
end

defp sync_session(%{assigns: %{session: %Session{name: name} = sess}} = socket) when is_binary(name) do
defp sync_session(%{assigns: %{session: %Session{id: id} = sess}} = socket) when is_binary(id) do
# initialises sangh if uninitiated (didnt init at Vyasa.Session)
{:ok, sangh} = Sangh.create_session()
sangh_sess = %{sess | sangh: sangh}
Expand Down

0 comments on commit 82e4ae0

Please sign in to comment.