timgremore commited on
Commit
0a57d6d
1 Parent(s): 8ef5db9

chore: Configure PubSub with an atom name

Browse files
config/config.exs CHANGED
@@ -22,7 +22,7 @@ config :medical_transcription, MedicalTranscriptionWeb.Endpoint,
22
  formats: [html: MedicalTranscriptionWeb.ErrorHTML, json: MedicalTranscriptionWeb.ErrorJSON],
23
  layout: false
24
  ],
25
- pubsub_server: MedicalTranscription.PubSub,
26
  live_view: [signing_salt: "wVVDe1It"]
27
 
28
  config :medical_transcription, :generators,
 
22
  formats: [html: MedicalTranscriptionWeb.ErrorHTML, json: MedicalTranscriptionWeb.ErrorJSON],
23
  layout: false
24
  ],
25
+ pubsub_server: :medicode_pubsub,
26
  live_view: [signing_salt: "wVVDe1It"]
27
 
28
  config :medical_transcription, :generators,
lib/medical_transcription/application.ex CHANGED
@@ -15,7 +15,7 @@ defmodule MedicalTranscription.Application do
15
  MedicalTranscription.Repo,
16
  {DNSCluster,
17
  query: Application.get_env(:medical_transcription, :dns_cluster_query) || :ignore},
18
- {Phoenix.PubSub, name: MedicalTranscription.PubSub},
19
  # Start the Finch HTTP client for sending emails
20
  {Finch, name: MedicalTranscription.Finch},
21
  transcription_spec(),
 
15
  MedicalTranscription.Repo,
16
  {DNSCluster,
17
  query: Application.get_env(:medical_transcription, :dns_cluster_query) || :ignore},
18
+ {Phoenix.PubSub, name: :medicode_pubsub},
19
  # Start the Finch HTTP client for sending emails
20
  {Finch, name: MedicalTranscription.Finch},
21
  transcription_spec(),
lib/medical_transcription_web/live/transcriptions_live/show.ex CHANGED
@@ -6,8 +6,10 @@ defmodule MedicalTranscriptionWeb.TranscriptionsLive.Show do
6
 
7
  @impl Phoenix.LiveView
8
  def mount(params, session, socket) do
9
- dbg(params)
10
- if connected?(socket), do: Phoenix.PubSub.subscribe(MedicalTranscription.PubSub, "transcriptions")
 
 
11
 
12
  # We're storing atoms in `:status` as LiveView's AsyncResult doesn't support modeling a "pending" state, but only
13
  # loading / ok / failed.
@@ -17,6 +19,7 @@ defmodule MedicalTranscriptionWeb.TranscriptionsLive.Show do
17
  status: :pending,
18
  audio_pipeline: nil,
19
  summary_keywords: [],
 
20
  transcriptions: list_transcriptions(session["current_user"]),
21
  finalized_codes: []
22
  }
@@ -212,10 +215,6 @@ defmodule MedicalTranscriptionWeb.TranscriptionsLive.Show do
212
  {:noreply, assign(socket, :status, :success)}
213
  end
214
 
215
- def error_to_string(:too_large), do: "Too large"
216
- def error_to_string(:not_accepted), do: "You have selected an unacceptable file type"
217
-
218
- defp list_transcriptions(user) do
219
- Transcriptions.list_transcriptions(user)
220
- end
221
  end
 
6
 
7
  @impl Phoenix.LiveView
8
  def mount(params, session, socket) do
9
+ transcription = get_transcription(params["id"])
10
+
11
+ if connected?(socket),
12
+ do: Phoenix.PubSub.subscribe(:medicode_pubsub, "transcriptions:#{transcription.id}")
13
 
14
  # We're storing atoms in `:status` as LiveView's AsyncResult doesn't support modeling a "pending" state, but only
15
  # loading / ok / failed.
 
19
  status: :pending,
20
  audio_pipeline: nil,
21
  summary_keywords: [],
22
+ transcription: transcription,
23
  transcriptions: list_transcriptions(session["current_user"]),
24
  finalized_codes: []
25
  }
 
215
  {:noreply, assign(socket, :status, :success)}
216
  end
217
 
218
+ defp get_transcription(id), do: Transcriptions.get_transcription!(id)
219
+ defp list_transcriptions(user), do: Transcriptions.list_transcriptions(user)
 
 
 
 
220
  end