Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
81cb5be
Use SheafDisplay fr composed sheaf view in discuss
rtshkmr Nov 19, 2024
5023450
Follow telegram ui for mark_quote in mark_content
rtshkmr Nov 20, 2024
a4d9dcc
Attempt to use hsla for colors
rtshkmr Nov 20, 2024
e719c1a
Fix functionality in TextareaAutoResize
rtshkmr Nov 20, 2024
998bee6
Fix Control Panel interference bug
rtshkmr Nov 20, 2024
98b1475
Use action_toggle_button for text-based buttons
rtshkmr Nov 20, 2024
78e07ae
Use action toggle button for marks edit
rtshkmr Nov 20, 2024
45587f4
Shift the edit buttongroups for marks inwards
rtshkmr Nov 20, 2024
b21fb63
Display clickable quote region for marks w/o quote
rtshkmr Nov 20, 2024
ea7beae
Rely on a fn for selector for pseudoform
rtshkmr Nov 21, 2024
fe4c134
Prettify indent guides, support tap to collapse
rtshkmr Nov 21, 2024
17a404f
Prevent zoom-out beyond 1x scale on mobile
rtshkmr Nov 21, 2024
8cdf697
Improve sheaf modal styling
rtshkmr Nov 29, 2024
3e0bcd1
Style SheafCreationForm's replyto_context_display
rtshkmr Dec 6, 2024
16697e2
Minor changes
rtshkmr Dec 6, 2024
8dac303
Fix issue in make_reply for root sheaf creation
rtshkmr Dec 7, 2024
e74a947
Fix sheaf::publish on discussions mode
rtshkmr Dec 7, 2024
80fa60c
Wire up 2 out of 4 of the alternative action btns
rtshkmr Dec 7, 2024
0e1cd6c
Add action btn to create new thread @ discuss mode
rtshkmr Dec 8, 2024
7950455
Fix the re-introduced scrolling bug
rtshkmr Dec 8, 2024
a3eeac3
Merge branch 'feat/discussion/sheaf-creation-modal' into feat/discuss…
rtshkmr Dec 8, 2024
f4ac084
Wire clear_reply_to, improve sheaf::publish
rtshkmr Dec 9, 2024
8ac06d3
Use push_js_cmd to dispatch js actions fm srv
rtshkmr Dec 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions lib/vyasa/sangh.ex
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,8 @@ defmodule Vyasa.Sangh do

# way number 3 -- no assoced parent (i.e. will be root sheaf), nothing to reconcile
def make_reply(
%Sheaf{
parent_id: nil
} = reply,
attrs
%Sheaf{} = reply,
%{parent: nil} = attrs
) do
Comment on lines 492 to 495

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[BUG] Odd bug again in sheaf creation @ make_reply()

likely need you to add verify this on the changeset side @ks0m1c

Not sure if the fix is actually something to be done at the changeset
level. In brief, the SOT should be the replyto context that
is in the socket state. So even if a sheaf may have a
currently-associated parent sheaf, if the socket says that the
parentid or parent is null then it's null (and a root sheaf).

See lib/vyasaweb/components/contexts/read.ex

def handle_event(
      "sheaf::publish",
      %{
        "body" => body
      } = _params,
      %Socket{
        assigns: %{
          draft_reflector: %Sheaf{} = draft_sheaf,
          draft_reflector_ui: %SheafUiState{
            marks_ui: %MarksUiState{} = _ui_state
          },
          reply_to: reply_to_sheaf,
          session: %VyasaWeb.Session{
            name: username,
            sangh: %Vyasa.Sangh.Session{
              id: sangh_id
            }
          }
        }
      } = socket
    ) do
  IO.inspect(%{body: body},
    label: "SHEAF CREATION without parent"
  )

  payload_precursor = %{
    body: body,
    traits: ["published"],
    signature: username,
    inserted_at: Utils.Time.get_utc_now()
  }

  # FIXME: the socket state should be the SOT. So even if the draft sheaf has an associated parent,
  # when my reply_to_sheaf is nil, then the parent should be set to nil if it gets published.
  # currently this is NOT happening, i.e. the parent assoc is still there, so the sheaf gets published but as a child of whatever the previous state was.
  reply_payload =
    case reply_to_sheaf do
      %Sheaf{} ->
        payload_precursor |> Map.put(:parent, reply_to_sheaf)

      nil ->
        # so the socket's reply_to will take priority, even if the draft sheaf may already an associated parent, this will take priority.
        payload_precursor |> Map.put(:parent, nil)
    end

  draft_sheaf
  |> Vyasa.Sangh.make_reply(reply_payload)

  {:noreply,
   socket
   |> ui_toggle_show_sheaf_modal?()
   |> register_sheaf(Sheaf.draft!(sangh_id))
   |> assign(reply_to: nil)
   |> cascade_stream_change()}
end

IO.puts("CHECKPOINT Make Reply way 3 -- no parent to associate to")
reply |> update_sheaf(attrs)
Expand Down
33 changes: 24 additions & 9 deletions lib/vyasa_web/components/contexts/discuss.ex
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,22 @@ defmodule VyasaWeb.Context.Discuss do
}
end

def handle_event(
"sheaf::clear_reply_to_context",
_,
%Socket{
assigns: %{
session: %{sangh: %{id: _sangh_id}},
draft_reflector_path: %Ltree{},
reply_to_path: _
}
} = socket
) do
{:noreply,
socket
|> assign(reply_to_path: nil)}
end

@impl true
# TODO @ks0m1c another place that would require binding / permalinking apis
# equivalent handler for the read mode as well...
Expand Down Expand Up @@ -700,7 +716,7 @@ defmodule VyasaWeb.Context.Discuss do
"sheaf::publish",
%{
"body" => body
} = params,
} = _params,
%Socket{
assigns: %{
session: %VyasaWeb.Session{
Expand All @@ -712,19 +728,15 @@ defmodule VyasaWeb.Context.Discuss do
draft_reflector_path: %Ltree{
labels: draft_sheaf_lattice_key
},
reply_to_path: %Ltree{
labels: reply_to_lattice_key
},
reply_to_path: reply_to_path,
sheaf_lattice: %{} = sheaf_lattice,
sheaf_ui_lattice: %{} = sheaf_ui_lattice
}
} = socket
)
when is_binary(body) do
# TODO: the reply_to_lattice_key might be nil, that case of "create new thread" is not handled right now by discuss
reply_to_sheaf = sheaf_lattice[reply_to_lattice_key]
reply_to_sheaf = reply_to_path && sheaf_lattice[reply_to_path.labels]
draft_sheaf = sheaf_lattice[draft_sheaf_lattice_key]
dbg()

payload_precursor = %{
body: body,
Expand All @@ -736,10 +748,10 @@ defmodule VyasaWeb.Context.Discuss do
update_payload =
case(is_nil(reply_to_sheaf)) do
true ->
payload_precursor
payload_precursor |> Map.put(:parent, nil)

false ->
Map.put(payload_precursor, :parent, reply_to_sheaf)
payload_precursor |> Map.put(:parent, reply_to_sheaf)
end

{:ok, updated_sheaf} = draft_sheaf |> Vyasa.Sangh.make_reply(update_payload)
Expand Down Expand Up @@ -788,11 +800,14 @@ defmodule VyasaWeb.Context.Discuss do
{:noreply, socket}
end

# FIXME: we need to improve how the modal show and hide is happening by calling the necessary
# JS-struct based functions, this is what is causing the scrolling bugs
def handle_event(
"navigate::see_discussion",
_,
socket
) do
IO.inspect("CHECKPOINT: the discuss context is reached")
send(self(), "ui::toggle_show_sheaf_modal?")
# target_path =
# curr_path
Expand Down
30 changes: 25 additions & 5 deletions lib/vyasa_web/components/contexts/read.ex
Original file line number Diff line number Diff line change
Expand Up @@ -834,18 +834,19 @@ defmodule VyasaWeb.Context.Read do
inserted_at: Utils.Time.get_utc_now()
}

# FIXME: the socket state should be the SOT. So even if the draft sheaf has an associated parent,
# when my reply_to_sheaf is nil, then the parent should be set to nil if it gets published.
# currently this is NOT happening.
reply_payload =
case reply_to_sheaf do
%Sheaf{} ->
payload_precursor |> Map.put(:parent, reply_to_sheaf)

nil ->
payload_precursor
# so the socket's reply_to will take priority, even if the draft sheaf may already an associated parent, this will take priority.
payload_precursor |> Map.put(:parent, nil)
end

dbg()
# FIXME: not sure why this is broken lol, just revisit the publishing routine properly

draft_sheaf
|> Vyasa.Sangh.make_reply(reply_payload)

Expand All @@ -857,6 +858,25 @@ defmodule VyasaWeb.Context.Read do
|> cascade_stream_change()}
end

def handle_event(
"sheaf::clear_reply_to_context",
_,
%Socket{
assigns: %{
draft_reflector: %Sheaf{} = _draft_sheaf,
draft_reflector_ui: %SheafUiState{
marks_ui: %MarksUiState{} = _ui_state
},
reply_to: _reply_to_sheaf
}
} = socket
) do
{:noreply,
socket
|> assign(reply_to: nil)
|> cascade_stream_change()}
end

@impl true
# TODO @ks0m1c this is an example of what binding/permalinking should handle
# we need to do a push-patch direction from this function
Expand Down Expand Up @@ -909,7 +929,7 @@ defmodule VyasaWeb.Context.Read do
# TODO: sheaf-crud: reply_to is currently set to the same as the active_sheaf
def render(assigns) do
~H"""
<div id={@id} class="flex-grow" >
<div id={@id} class="flex-grow">
<!-- CONTENT DISPLAY: -->
<div id="content-display" class="mx-auto max-w-2xl">
<%= if @content_action == :show_sources do %>
Expand Down