Skip to content

Commit

Permalink
Media feed
Browse files Browse the repository at this point in the history
  • Loading branch information
mayel committed Jan 24, 2024
1 parent 0b6052a commit 69cd760
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 26 deletions.
41 changes: 24 additions & 17 deletions lib/components/activity/activity_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -397,17 +397,18 @@ defmodule Bonfire.UI.Social.ActivityLive do
activity_component_id,
subject_user
) do
(component_maybe_in_reply_to(
verb,
activity,
showing_within,
activity_inception,
viewing_main_object,
thread_mode,
thread_id,
thread_title,
activity_component_id
) ++
(component_maybe_attachments(showing_within == :media, activity, object, activity_inception) ++
component_maybe_in_reply_to(
verb,
activity,
showing_within,
activity_inception,
viewing_main_object,
thread_mode,
thread_id,
thread_title,
activity_component_id
) ++
component_activity_subject(
verb,
activity,
Expand All @@ -418,12 +419,7 @@ defmodule Bonfire.UI.Social.ActivityLive do
subject_user
) ++
component_object(object, object_type) ++
component_maybe_attachments(
id(object) || id(activity),
e(activity, :files, nil) || e(object, :files, nil) || e(activity, :media, nil) ||
e(object, :media, nil),
activity_inception
) ++
component_maybe_attachments(showing_within != :media, activity, object, activity_inception) ++
component_actions(
verb,
activity,
Expand All @@ -440,6 +436,17 @@ defmodule Bonfire.UI.Social.ActivityLive do
|> debug("components")
end

defp component_maybe_attachments(true, activity, object, activity_inception) do
component_maybe_attachments(
id(object) || id(activity),
e(activity, :files, nil) || e(object, :files, nil) || e(activity, :media, nil) ||
e(object, :media, nil),
activity_inception
)
end

defp component_maybe_attachments(_, _activity, _object, _activity_inception), do: []

def maybe_prepare(%{activity: _, activity_prepared: true} = assigns) do
assigns
end
Expand Down
13 changes: 5 additions & 8 deletions lib/components/activity/media/academic_paper_live.sface
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@
<div class="text-sm text-left">
<div class="mt-2">
<!-- <div class="uppercase font-medium text-base-content/70 text-xs">{l("authors")}</div> -->
<div class="flex flex-wrap gap-0.5">
<div class="flex flex-wrap gap-0.5 text-sm text-base-content/80">
{#for author <-
Enum.intersperse(List.wrap(e(@metadata, "creators", []) || e(@metadata, "author", [])), ",")}
<span class="text-sm text-base-content/80">
{#if is_map(author)}
{e(author, "given", nil) || e(author, "firstName", nil)} {e(author, "family", nil) || e(author, "lastName", nil)}
{#else}
{author}
{/if}
</span>
{#if is_map(author)}
{e(author, "given", nil) || e(author, "firstName", nil)} {e(author, "family", nil) || e(author, "lastName", nil)}
{#else}{author}
{/if}
{/for}
</div>

Expand Down
5 changes: 4 additions & 1 deletion lib/components/activity/media/media_live.sface
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<div :if={@link_list != [] && @showing_within != :smart_input} class="my-2 flex flex-col gap-2">
<div
:if={@link_list != [] && @showing_within != :smart_input}
class={"my-2 flex flex-col gap-2", "-ml-[2.5rem] mb-4": @showing_within == :media}
>
{!-- LINKS --}
{#for m <- @link_list}
{#case Media.media_url(m)}
Expand Down

0 comments on commit 69cd760

Please sign in to comment.