Skip to content

Commit

Permalink
GRN2-xx: Added an auto-refresh after 2 mins while waiting for room to…
Browse files Browse the repository at this point in the history
… start (#1947)

* Added an auto-refresh after 2 mins while waiting for room to start

* Fixed random issue with test case
  • Loading branch information
farhatahmad committed Jul 28, 2020
1 parent db8eea2 commit 894e361
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
12 changes: 12 additions & 0 deletions app/assets/javascripts/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ $(document).on('turbolinks:load', function(){
$("#create-room-block").click(function(){
showCreateRoom(this)
})

checkIfAutoJoin()
}

// Autofocus on the Room Name label when creating a room only
Expand Down Expand Up @@ -263,4 +265,14 @@ function removeSharedUser(target) {
parentLI.removeChild(target)
parentLI.classList.add("remove-shared")
}
}

// Automatically click the join button if this is an action cable reload
function checkIfAutoJoin() {
var url = new URL(window.location.href)

if (url.searchParams.get("reload") == "true") {
$("#joiner-consent").click()
$("#room-join").click()
}
}
8 changes: 8 additions & 0 deletions app/assets/javascripts/wait.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ $(document).on("turbolinks:load", function(){
}, {
connected: function() {
console.log("connected");
setTimeout(startRefreshTimeout, 120000);
},

disconnected: function(data) {
Expand Down Expand Up @@ -68,3 +69,10 @@ var request_to_join_meeting = function(){
}
});
}

// Refresh the page after 2 mins and attempt to reconnect to ActionCable
function startRefreshTimeout() {
var url = new URL(window.location.href)
url.searchParams.set("reload","true")
window.location.href = url.href
}
4 changes: 2 additions & 2 deletions app/views/rooms/join.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@
autofocus: true
%>
<span class="input-group-append">
<button type="submit" class="btn btn-primary btn-sm px-7 form-control join-form">
<button id="room-join" type="submit" class="btn btn-primary btn-sm px-7 form-control join-form">
<%= (!@room_running && @anyone_can_start) ? t("room.start") : t("room.join") %>
</button>
</span>
</div>
<% if recording_consent_required? && @room.recording_enabled? %>
<label class="custom-control custom-checkbox">
<input id="delete-checkbox" type="checkbox" class="custom-control-input" required>
<input id="joiner-consent" type="checkbox" class="custom-control-input" required>
<h4 class="text-left text-danger mt-4 custom-control-label"><%= t("room.recording_present") %></h4>
</label>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/rooms_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ def random_valid_room_params

it "properly updates room name through the room settings modal and redirects to current page" do
@request.session[:user_id] = @user.id
name = Faker::Games::Pokemon.name
name = Faker::Name.first_name

room_params = { room_uid: @secondary_room.uid, room: { "name": name } }

Expand Down

0 comments on commit 894e361

Please sign in to comment.