Noah Settersten commited on
Commit
a6485ec
·
1 Parent(s): 139ee5c

feat: Allow re-enabling recording from the result heading

Browse files
lib/medical_transcription_web/components/components.ex CHANGED
@@ -55,18 +55,15 @@ defmodule MedicalTranscriptionWeb.Components do
55
  ~H"""
56
  <div class="flex justify-between">
57
  <div class="flex items-center">
58
- <%= if Enum.member?([:loading, :streaming_audio], @status) do %>
59
- <img src={~p"/images/loading.svg"} width="36" class="mr-6 animate-spin" />
60
- <% end %>
61
- <%= if @status == :streaming_audio do %>
62
- <button phx-click="toggle_recording" class="mr-6 p-4 bg-red-200 rounded-lg">
63
- <.icon name="hero-microphone" class="animate-pulse" />
64
- </button>
65
  <% end %>
66
 
67
- <%= if @status == :success do %>
68
- <img src={~p"/images/checkmark.svg"} width="46" class="mr-[17px]" />
69
- <% end %>
70
  <div class="px-[14px] py-3 flex items-center gap-3 bg-brand rounded-lg text-white">
71
  <img src={~p"/images/document.svg"} width="20" />
72
  <span class="font-secondary"><%= @filename %></span>
@@ -106,6 +103,22 @@ defmodule MedicalTranscriptionWeb.Components do
106
  end
107
  end
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  def format_keywords(keyword_predictions) do
110
  keyword_predictions
111
  |> List.flatten()
 
55
  ~H"""
56
  <div class="flex justify-between">
57
  <div class="flex items-center">
58
+ <%= case @status do %>
59
+ <% status when status in [:loading, :streaming_audio] -> %>
60
+ <img src={~p"/images/loading.svg"} width="36" class="mr-6 animate-spin" />
61
+ <% :success -> %>
62
+ <img src={~p"/images/checkmark.svg"} width="46" class="mr-[17px]" />
 
 
63
  <% end %>
64
 
65
+ <.record_button_in_heading status={@status} />
66
+
 
67
  <div class="px-[14px] py-3 flex items-center gap-3 bg-brand rounded-lg text-white">
68
  <img src={~p"/images/document.svg"} width="20" />
69
  <span class="font-secondary"><%= @filename %></span>
 
103
  end
104
  end
105
 
106
+ def record_button_in_heading(assigns) when assigns.status == :streaming_audio do
107
+ ~H"""
108
+ <button phx-click="toggle_recording" class="mr-6 px-4 py-3 bg-red-200 rounded-lg">
109
+ <.icon name="hero-microphone" class="animate-pulse" />
110
+ </button>
111
+ """
112
+ end
113
+
114
+ def record_button_in_heading(assigns) do
115
+ ~H"""
116
+ <button phx-click="toggle_recording" class="mr-6 px-4 py-3 bg-emerald-200 rounded-lg">
117
+ <.icon name="hero-microphone" />
118
+ </button>
119
+ """
120
+ end
121
+
122
  def format_keywords(keyword_predictions) do
123
  keyword_predictions
124
  |> List.flatten()
lib/medical_transcription_web/live/home_live/index.ex CHANGED
@@ -107,9 +107,17 @@ defmodule MedicalTranscriptionWeb.HomeLive.Index do
107
 
108
  @impl true
109
  def handle_event("toggle_recording", _params, socket) do
 
 
 
 
 
 
 
110
  socket =
111
  socket
112
- |> assign(:recording, !socket.assigns.recording)
 
113
  |> start_pipeline_if_needed()
114
  |> stop_pipeline_if_needed()
115
 
 
107
 
108
  @impl true
109
  def handle_event("toggle_recording", _params, socket) do
110
+ new_status =
111
+ if socket.assigns.recording do
112
+ :success
113
+ else
114
+ :streaming_audio
115
+ end
116
+
117
  socket =
118
  socket
119
+ |> assign(:recording, new_status == :streaming_audio)
120
+ |> assign(:status, new_status)
121
  |> start_pipeline_if_needed()
122
  |> stop_pipeline_if_needed()
123