defmodule MedicalTranscriptionWeb.Components.TranscriptionTextComponent do @moduledoc """ Represents a portion of transcribed text and its codes and starts a task to determine keywords within the text. """ use MedicalTranscriptionWeb, :live_component import MedicalTranscriptionWeb.Components import MedicalTranscriptionWeb.Components.KeywordHighlighter alias AudioTagger.Structs.TagResult @impl Phoenix.LiveComponent def update(assigns, socket) do self_pid = self() socket = if Map.has_key?(assigns, :row) do socket |> assign(:row, assigns.row) |> assign_async(:keywords, fn -> find_keywords(self_pid, assigns.row.text) end) else socket end {:ok, socket} end @impl Phoenix.LiveComponent def render(assigns) do ~H"""
<%= if !@row.is_summary do %> <%= @row.start_mark %> - <%= @row.end_mark %> <% end %>
<.async_result :let={keywords} assign={@keywords}> <:loading><%= @row.text %> <.highlight text={@row.text} keywords={keywords} />