Skip to content

Commit

Permalink
https://github.com/bonfire-networks/bonfire-app/issues/831
Browse files Browse the repository at this point in the history
  • Loading branch information
mayel committed Jan 25, 2024
1 parent 69cd760 commit 176249d
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 29 deletions.
5 changes: 3 additions & 2 deletions lib/components/activity/actions/more_actions_live.sface
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@
</li>
{/if}

<li>
<li :if={extension_enabled?(:bonfire_ui_topics) or extension_enabled?(:bonfire_ui_groups)}>
<StatelessComponent
module={maybe_component(Bonfire.Classify.Web.TagModalLive, @__context__)}
module={maybe_component(Bonfire.Tag.Web.TagModalLive, @__context__)}
object={@object}
parent_id={@activity_component_id || id(@activity)}
/>
Expand Down Expand Up @@ -222,6 +222,7 @@
module={maybe_component(Bonfire.Label.Web.ContentLabelLive, @__context__)}
object={@object}
object_boundary={@object_boundary}
target={"##{@activity_component_id}"}
/>

{!-- Block the author, etc --}
Expand Down
26 changes: 24 additions & 2 deletions lib/components/activity/activity_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ defmodule Bonfire.UI.Social.ActivityLive do
existing -> existing
end,
published_in: maybe_published_in(activity, extras[:verb]),
labelled: maybe_labelled(activity, extras[:verb]),
# e(socket_assigns[:activity], :peered, nil) != nil or
is_remote:
(assigns[:is_remote] || socket_assigns[:is_remote] ||
Expand Down Expand Up @@ -378,8 +379,17 @@ defmodule Bonfire.UI.Social.ActivityLive do
parent_id
end

def maybe_published_in(_none, _) do
# debug(none, "none")
def maybe_published_in(none, verb) do
# debug(none, "none for #{verb}")
nil
end

def maybe_labelled(%{subject: %{table_id: "2AGSCANBECATEG0RY0RHASHTAG"} = subject}, "Label") do
subject
end

def maybe_labelled(none, verb) do
debug(none, "none for #{verb}")
nil
end

Expand Down Expand Up @@ -570,6 +580,12 @@ defmodule Bonfire.UI.Social.ActivityLive do
<input type="hidden" name="activity_id" value={@activity_id}>
</form>
<Bonfire.UI.Social.Activity.PublishedInLive
:if={@published_in && @showing_within != :smart_input}
context={@published_in}
showing_within={@showing_within}
/>
{#for {component, component_assigns} when is_atom(component) <-
activity_components(
@activity,
Expand Down Expand Up @@ -769,6 +785,12 @@ defmodule Bonfire.UI.Social.ActivityLive do
/>
{/case}
{/for}
<Bonfire.UI.Social.Activity.LabelledLive
:if={@labelled && @showing_within != :smart_input}
labelled={@labelled}
showing_within={@showing_within}
/>
{/if}
</article>
"""
Expand Down
7 changes: 7 additions & 0 deletions lib/components/activity/context/labelled_live.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defmodule Bonfire.UI.Social.Activity.LabelledLive do
use Bonfire.UI.Common.Web, :stateless_component

prop labelled, :any, default: nil
prop showing_within, :atom, default: nil
prop class, :css_class, default: ["flex items-center -ml-6 justify-start pb-2 mb-2"]
end
24 changes: 24 additions & 0 deletions lib/components/activity/context/labelled_live.sface
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div
:if={@showing_within not in [:group, :topic, :thread] and not is_nil(@labelled)}
class={@class}
>
<!-- <#Icon iconify="ri:group-fill" class="w-4 h-4 text-info" /> -->
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
class="stroke-current shrink-0 w-6 h-6"
><path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
/></svg>
<div class="flex-1 ml-3">
<div class="text-sm font-medium text-base-content/70">
<LiveRedirect class="font-medium link text-base-content/70" to={path(@labelled)}>
{e(@labelled, :profile, :name, nil) || e(@labelled, :character, :username, nil)}
</LiveRedirect>
</div>
</div>
</div>
5 changes: 0 additions & 5 deletions lib/components/activity/subject/no_subject_live.sface
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
<div data-role="no_subject" class="flex items-end w-full">
<Bonfire.UI.Social.Activity.PublishedInLive
:if={@published_in && @showing_within != :smart_input}
context={@published_in}
/>

<Bonfire.UI.Social.Activity.InstanceIconLive peered={@peered} />

<Bonfire.UI.Social.Activity.LinkToActivityLive
Expand Down
5 changes: 0 additions & 5 deletions lib/components/activity/subject/subject_live.sface
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
<Bonfire.UI.Social.Activity.PublishedInLive
:if={@published_in && @showing_within != :smart_input}
context={@published_in}
/>

<div
data-id="subject"
data-main-object={@viewing_main_object}
Expand Down
15 changes: 0 additions & 15 deletions lib/live_handlers/objects_live_handler.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,6 @@ defmodule Bonfire.Social.Objects.LiveHandler do
end
end

def handle_event("tag", %{"tags" => tags} = params, socket) do
with {:ok, _} <-
Bonfire.Social.Tags.maybe_tag(
current_user_required!(socket),
e(params, "id", nil) || e(socket.assigns, :object, nil),
tags
) do
Bonfire.UI.Common.OpenModalLive.close()

{:noreply,
socket
|> assign_flash(:info, l("Tagged!"))}
end
end

def handle_event("delete", %{"id" => id} = _params, socket) do
with {:ok, _} <-
Objects.delete(id,
Expand Down

0 comments on commit 176249d

Please sign in to comment.