diff --git a/web/app/assets/javascripts/react-components/FindSessionRow.js.jsx.coffee b/web/app/assets/javascripts/react-components/FindSessionRow.js.jsx.coffee
index 53bc1cc48..138d12e3f 100644
--- a/web/app/assets/javascripts/react-components/FindSessionRow.js.jsx.coffee
+++ b/web/app/assets/javascripts/react-components/FindSessionRow.js.jsx.coffee
@@ -30,18 +30,24 @@ SessionUtils = context.JK.SessionUtils
instruments
createLatencyBadge: (userId) ->
- logger.debug(">>>PARTICIPANT", userId)
- logger.debug(">>>userLatencies", @state.userLatencies)
- logger.debug(">>>userLatenciesFailed", @state.userLatenciesFailed)
- latency = @state.userLatencies.find((userLatency) ->
- userLatency.user_id == userId
- )
- failed = @state.userLatenciesFailed.find((failedId) ->
- failedId == userId
- )
+ #logger.debug(">>>PARTICIPANT", userId)
+ #logger.debug(">>>userLatencies", @state.userLatencies)
+ #logger.debug(">>>userLatenciesFailed", @state.userLatenciesFailed)
+ latency = null
+ failed = false
- logger.debug(">>>latencies=====>>>>", latency)
- logger.debug(">>>Failed=======>>>>>", failed)
+ if @state.userLatencies.latencies
+ latency = @state.userLatencies.latencies.find((userLatency) ->
+ userLatency.user_id == userId
+ )
+
+ if @state.userLatenciesFailed
+ failed = @state.userLatenciesFailed.find((failedId) ->
+ failedId == userId
+ )
+
+ logger.debug(">>>createLatencyBadge.latency = ", latency)
+ logger.debug(">>>createLatencyBadge.failed =", failed)
``
@@ -414,6 +420,7 @@ SessionUtils = context.JK.SessionUtils
null
onLatencyUpdate: (latencyResp) ->
+ logger.debug("latencyResp}}}}}}}}}}}}}}}}", latencyResp)
if latencyResp.users
@setState(userLatencies: latencyResp.users)
else if latencyResp.user_ids
diff --git a/web/app/assets/javascripts/react-components/LatencyBadge.js.jsx.coffee b/web/app/assets/javascripts/react-components/LatencyBadge.js.jsx.coffee
index 337eb4007..82449bd2b 100644
--- a/web/app/assets/javascripts/react-components/LatencyBadge.js.jsx.coffee
+++ b/web/app/assets/javascripts/react-components/LatencyBadge.js.jsx.coffee
@@ -13,65 +13,63 @@ LATENCY = {
render: () ->
latencyDescription = @props.failed
- # if @props.latency
- # latency = @props.latency
- # full_score = latency.ars.total_latency
- # internet_score = parseInt(latency.internet_score);
- # audio_latency = parseInt(latency.audio_latency);
+ if @props.latency
+ latency = @props.latency
+ full_score = latency.ars.total_latency
+ internet_score = parseInt(latency.internet_score);
+ audio_latency = parseInt(latency.audio_latency);
- # latencyDescription = "XXXX"
- # latencyStyle = ""
- # iconName = ""
- # description = ""
- # latencyDetails = ""
+ latencyDescription = ""
+ latencyStyle = ""
+ iconName = ""
+ description = ""
+ latencyDetails = ""
- # # if !full_score || full_score <= LATENCY.UNKNOWN.max
- # # latencyDescription = LATENCY.UNKNOWN.description
- # # latencyStyle = LATENCY.UNKNOWN.style
- # # iconName = "purple"
- # # description = "missing"
- # # latencyDetails = ""
- # # else if full_score <= LATENCY.GOOD.max
- # # latencyDescription = LATENCY.GOOD.description
- # # latencyStyle = LATENCY.GOOD.style;
- # # iconName = "green"
- # # description = "good"
- # # latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms"
- # # else if full_score <= LATENCY.MEDIUM.max
- # # latencyDescription = LATENCY.MEDIUM.description
- # # latencyStyle = LATENCY.MEDIUM.style
- # # iconName = "yellow"
- # # description = "fair"
- # # latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms"
- # # else if full_score <= LATENCY.POOR.max
- # # latencyDescription = LATENCY.POOR.description
- # # latencyStyle = LATENCY.POOR.style
- # # iconName = "red"
- # # description = "poor"
- # # latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms"
- # # else if full_score > LATENCY.UNACCEPTABLE.min
- # # latencyDescription = LATENCY.UNACCEPTABLE.description
- # # latencyStyle = LATENCY.UNACCEPTABLE.style
- # # iconName = "blue"
- # # description = "unacceptable"
- # # latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms"
+ if !full_score || full_score <= LATENCY.UNKNOWN.max
+ latencyDescription = LATENCY.UNKNOWN.description
+ latencyStyle = LATENCY.UNKNOWN.style
+ iconName = "purple"
+ description = "missing"
+ latencyDetails = ""
+ else if full_score <= LATENCY.GOOD.max
+ latencyDescription = LATENCY.GOOD.description
+ latencyStyle = LATENCY.GOOD.style;
+ iconName = "green"
+ description = "good"
+ latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms"
+ else if full_score <= LATENCY.MEDIUM.max
+ latencyDescription = LATENCY.MEDIUM.description
+ latencyStyle = LATENCY.MEDIUM.style
+ iconName = "yellow"
+ description = "fair"
+ latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms"
+ else if full_score <= LATENCY.POOR.max
+ latencyDescription = LATENCY.POOR.description
+ latencyStyle = LATENCY.POOR.style
+ iconName = "red"
+ description = "poor"
+ latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms"
+ else if full_score > LATENCY.UNACCEPTABLE.min
+ latencyDescription = LATENCY.UNACCEPTABLE.description
+ latencyStyle = LATENCY.UNACCEPTABLE.style
+ iconName = "blue"
+ description = "unacceptable"
+ latencyDetails = "Internet #{internet_score}ms + Audio #{audio_latency}ms"
- # else if @props.failed
- # latencyDescription = LATENCY.FAILED.description
- # latencyStyle = LATENCY.FAILED.style
- # iconName = "gray"
- # description = "failed"
- # latencyDetails = ""
- # else
- # latencyDescription = @props
-
- # {
- # latency_style: latencyStyle,
- # latency_text: latencyDescription,
- # icon_name: iconName,
- # description: description,
- # latency_details: latencyDetails
- # }
+ else if @props.failed
+ latencyDescription = LATENCY.FAILED.description
+ latencyStyle = LATENCY.FAILED.style
+ iconName = "gray"
+ description = "failed"
+ latencyDetails = ""
+
+ {
+ latency_style: latencyStyle,
+ latency_text: latencyDescription,
+ icon_name: iconName,
+ description: description,
+ latency_details: latencyDetails
+ }
`{latencyDescription}`
diff --git a/web/spec/features/find_sessions_latency_badge_spec.rb b/web/spec/features/find_sessions_latency_badge_spec.rb
index ae26455a9..1b6279ea8 100644
--- a/web/spec/features/find_sessions_latency_badge_spec.rb
+++ b/web/spec/features/find_sessions_latency_badge_spec.rb
@@ -38,7 +38,6 @@ describe "Find session latency badge", js: true, type: :feature, capybara_featur
end
end
-
before(:all) do
Capybara.default_max_wait_time = 10
end
@@ -51,12 +50,10 @@ describe "Find session latency badge", js: true, type: :feature, capybara_featur
create_and_join_session(creator_user, joiner_user)
end
-
it "show GOOD" do
in_client(finder_user) do
creator_response_body = mock_latency_response([{ user: creator_user, ars_total_latency: 1.0, ars_internet_latency: 0.5, audio_latency: 0.5 }]) #sessionUtils.LATENCY.GOOD : {description: "GOOD", style: "latency-good", min: 0.0, max: 40.0},
-
-
+
stub_request(:post, latency_data_uri)
.with(
:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}
@@ -70,7 +67,7 @@ describe "Find session latency badge", js: true, type: :feature, capybara_featur
find("a", text: "Open Jams").click
expect(page).to have_selector("#sessions-active .found-session table.musicians-category tr", count: 2)
- #expect(page).to have_selector("div.latency-badge[data-user-id=\"#{creator_user.id}\"]", text: "GOOD")
+ expect(page).to have_selector("div.latency-badge[data-user-id=\"#{creator_user.id}\"]", text: "GOOD")
#expect(page).to have_selector("div.latency-badge[data-user-id=\"#{joiner_user.id}\"]", text: "GOOD")