From 76aefd622737482bb1355263e772cb42a74eec09 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Mon, 17 Mar 2025 15:51:59 +0530 Subject: [PATCH] wip on leaving a session while recording --- ruby/lib/jam_ruby/models/connection.rb | 6 +++--- ruby/lib/jam_ruby/models/recording.rb | 2 +- .../react-components/stores/SessionStore.js.coffee | 2 ++ web/app/assets/javascripts/recordingModel.js | 12 +++++++++--- web/app/assets/javascripts/session.js | 1 + web/app/assets/javascripts/session_utils.js | 9 +++++---- 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/ruby/lib/jam_ruby/models/connection.rb b/ruby/lib/jam_ruby/models/connection.rb index a6a96b315..47abee3cc 100644 --- a/ruby/lib/jam_ruby/models/connection.rb +++ b/ruby/lib/jam_ruby/models/connection.rb @@ -145,9 +145,9 @@ module JamRuby end end - if music_session.is_recording? - errors.add(:music_session, ValidationMessages::CANT_JOIN_RECORDING_SESSION) - end + # if music_session.is_recording? + # errors.add(:music_session, ValidationMessages::CANT_JOIN_RECORDING_SESSION) + # end # same logic as Search.scope_schools_together_sessions if !self.user.is_platform_instructor diff --git a/ruby/lib/jam_ruby/models/recording.rb b/ruby/lib/jam_ruby/models/recording.rb index 25bd1628c..d9eba2a4a 100644 --- a/ruby/lib/jam_ruby/models/recording.rb +++ b/ruby/lib/jam_ruby/models/recording.rb @@ -32,7 +32,7 @@ module JamRuby foreign_key: :foreign_key1_id, dependent: :destroy - validate :not_already_recording, :on => :create + #validate :not_already_recording, :on => :create #validate :not_still_finalizing_previous, :on => :create validate :not_playback_recording, :on => :create validate :already_stopped_recording diff --git a/web/app/assets/javascripts/react-components/stores/SessionStore.js.coffee b/web/app/assets/javascripts/react-components/stores/SessionStore.js.coffee index 1c243c4bc..a96d5c9a6 100644 --- a/web/app/assets/javascripts/react-components/stores/SessionStore.js.coffee +++ b/web/app/assets/javascripts/react-components/stores/SessionStore.js.coffee @@ -1391,6 +1391,7 @@ ConfigureTracksActions = @ConfigureTracksActions return this.app.notifyAlert("No Inputs Configured", $('You will need to reconfigure your audio device.')); } else if (response["errors"] && response["errors"]["music_session"] && (response["errors"]["music_session"][0] === ["is currently recording"])) { + alert("Unable to Join Session", "The session is currently recording."); leaveBehavior = { location: "/client#/findSession", notify: { @@ -2007,6 +2008,7 @@ ConfigureTracksActions = @ConfigureTracksActions # @issueChange() performLeaveSession: `async function(deferred) { + alert('SessionStore#performLeaveSession') logger.debug("SessionModel.leaveCurrentSession()"); logger.debug("performLeaveSession: calling jamClient.LeaveSession for clientId=" + this.app.clientId); diff --git a/web/app/assets/javascripts/recordingModel.js b/web/app/assets/javascripts/recordingModel.js index a2fba0c8f..553ffea91 100644 --- a/web/app/assets/javascripts/recordingModel.js +++ b/web/app/assets/javascripts/recordingModel.js @@ -115,7 +115,7 @@ } /** Nulls can be passed for all 3 currently; that's a user request. */ - function stopRecording(recordingId, reason, detail) { + function stopRecording(recordingId, reason, detail, serverStop = false) { if(stoppingRecording) { logger.debug("ignoring stopRecording because we are already stopping"); return; @@ -139,7 +139,13 @@ // logger.debug("preemptive stop media") //context.jamClient.SessionStopPlay(); //} - await jamClient.StopRecording(recording.id, groupedTracks); + + if(serverStop){ + await jamClient.PeerStopRecording(recording.id, groupedTracks); + }else{ + await jamClient.StopRecording(recording.id, groupedTracks); + } + rest.stopRecording( { "id": recording.id } ) .done(function() { @@ -203,7 +209,7 @@ } function onServerStopRecording(recordingId) { - stopRecording(recordingId, null, null); + stopRecording(recordingId, null, null, true); } function handleRecordingStartResult(recordingId, result) { diff --git a/web/app/assets/javascripts/session.js b/web/app/assets/javascripts/session.js index fa14f5316..62aabda9c 100644 --- a/web/app/assets/javascripts/session.js +++ b/web/app/assets/javascripts/session.js @@ -470,6 +470,7 @@ app.notifyAlert("No Inputs Configured", $('You will need to reconfigure your audio device.')); } else if(response["errors"] && response["errors"]["music_session"] && response["errors"]["music_session"][0] == ["is currently recording"]) { + alert("session.js#sessionModel.joinSession The session is currently recording."); promptLeave = false; context.window.location = "/client#/findSession"; app.notify( { title: "Unable to Join Session", text: "The session is currently recording." }, null, true); diff --git a/web/app/assets/javascripts/session_utils.js b/web/app/assets/javascripts/session_utils.js index 5794832a8..e41a055e1 100644 --- a/web/app/assets/javascripts/session_utils.js +++ b/web/app/assets/javascripts/session_utils.js @@ -211,10 +211,11 @@ rest.getSession(sessionId) .done(function(response) { session = response; - if(session && session.recording) { - context.JK.app.notify( { title: "Unable to Join Session", text: "The session is currently recording." }, null, true); - return; - } + // if(session && session.recording) { + // alert("sessionUtils.joinSession#The session is currently recording."); + // context.JK.app.notify( { title: "Unable to Join Session", text: "The session is currently recording." }, null, true); + // return; + // } if (session) { if (session.can_join) {