From 02666d1680a5839749a834b2f01dd8b2a6daf27d Mon Sep 17 00:00:00 2001 From: Seth Call Date: Sun, 8 Jun 2025 14:34:10 -0500 Subject: [PATCH] Working on so far. at coffee shop pause --- .../SessionRecordingStatus.js.jsx.coffee | 6 +- .../stores/RecordingStore.js.jsx.coffee | 168 ------------------ web/app/assets/javascripts/recordingModel.js | 36 ++-- .../react-components/SessionScreen.scss | 2 +- 4 files changed, 27 insertions(+), 185 deletions(-) delete mode 100644 web/app/assets/javascripts/react-components/stores/RecordingStore.js.jsx.coffee diff --git a/web/app/assets/javascripts/react-components/SessionRecordingStatus.js.jsx.coffee b/web/app/assets/javascripts/react-components/SessionRecordingStatus.js.jsx.coffee index 09d2bc862..1fa82f09a 100644 --- a/web/app/assets/javascripts/react-components/SessionRecordingStatus.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/SessionRecordingStatus.js.jsx.coffee @@ -4,8 +4,6 @@ RecordingStore = @RecordingStore mixins: [Reflux.listenTo(@RecordingStore, "onRecordingChanged")] onRecordingChanged: (details) -> - console.log("SessionRecordingStatus RECORDING CHANGED ", details) - @setState(details) getInitialState: () -> @@ -32,8 +30,6 @@ RecordingStore = @RecordingStore cause = `cause={this.state.cause}` - console.log("modelState ", modelState, modelState?.waitingOnClientStop, modelState?.waitingOnServerStop) - waitingOnClientStop = null waitingOnServerStop = null if modelState? @@ -44,7 +40,7 @@ RecordingStore = @RecordingStore events = [] for event in @state.events - events.push(`
  • {event[0]}
  • `) + events.push(`
  • {event[0]} brid={event[1]}
  • `) body = `
    {recording} {cause} {waitingOnClientStop} {waitingOnServerStop}
    ` `
    diff --git a/web/app/assets/javascripts/react-components/stores/RecordingStore.js.jsx.coffee b/web/app/assets/javascripts/react-components/stores/RecordingStore.js.jsx.coffee deleted file mode 100644 index 78f96a732..000000000 --- a/web/app/assets/javascripts/react-components/stores/RecordingStore.js.jsx.coffee +++ /dev/null @@ -1,168 +0,0 @@ -$ = jQuery -context = window -logger = context.JK.logger - -BackendToFrontendFPS = { - - 0: 30, - 1: 24, - 2: 20, - 3: 15, - 4: 10 -} - -@RecordingStore = Reflux.createStore( - { - listenables: @RecordingActions - #recordingWindow: null - recordingWindowOpened: false - events: [] - - init: -> - # Register with the app store to get @app - this.listenTo(context.AppStore, this.onAppInit) - - onSessionEnded: () -> - if @recordingWindowOpened - #@recordingWindow.close() - @closeRecordingWindow() - - onAppInit: (app) -> - @app = app - $(context.AppStore).on('SessionEnded', @onSessionEnded) - - onInitModel: (recordingModel) -> - @recordingModel = recordingModel - @events=[] - this.trigger({isRecording: @recordingModel.isRecording(), events:@events}) - - # onStartRecording: (recordVideo, recordChat) -> - # frameRate = 0 - # if recordVideo - # if context.jamClient.GetCurrentVideoFrameRate? - # frameRate = context.jamClient.GetCurrentVideoFrameRate() || 0; - # frameRate = BackendToFrontendFPS[frameRate] - - # NoVideoRecordActive = 0 - # WebCamRecordActive = 1 - # ScreenRecordActive = 2 - # logger.debug("onStartRecording: recordVideo: #{recordVideo}, recordChat: #{recordChat} frameRate: #{frameRate}") - # @recordingModel.startRecording(recordVideo, recordChat, frameRate) - - onResetRecordingState: () -> - console.log("onResetRecordingState") - this.trigger({isRecording: @recordingModel.isRecording(), cause: '', events:@events}) - - onStartRecording: (recordSettings) -> - @recordingModel.startRecording(recordSettings); - @events=[] - @events.push(["StartRecording"]); - augmentWithBackendRecordingId(@events) - - this.trigger(events:@events) - - onStopRecording: () -> - @recordingModel.stopRecording() - @events.push(["StopRecording"]); - augmentWithBackendRecordingId(@events) - - this.trigger(events:@events) - - onStartingRecording: (details) -> - details.cause = 'starting' - @mixTransferred = false - @events.push(["OnStartingRecording"]) - - augmentWithBackendRecordingId(@events) - - details.events = @events - this.trigger(details) - @popupRecordingControls() unless @recordingWindowOpened - - augmentWithBackendRecordingId(events) - # REMOVE ME - backendRecordingId = await context.jamClient.GetCurrentRecordingId(); - event.at(-1).push(backendRecordindId) - - onStartedRecording: (details) -> - details.cause = 'started' - @mixTransferred = false - @events.push(["OnStartedRecording"]) - details.events = @events - augmentWithBackendRecordingId(details) - this.trigger(details) - - #@popupRecordingControls() unless @recordingWindowOpened - @closeRecordingWindow() if @recordingWindowOpened - - onStoppingRecording: (details) -> - details.cause = 'stopping' - @events.push(["OnStoppingRecording"]) - details.events = @events - - augmentWithBackendRecordingId(@events) - - - this.trigger(details) - - onStoppedRecording: (details) -> - details.cause = 'stopped' - @events.push(["OnStoppedRecording"]) - details.events = @events - - augmentWithBackendRecordingId(@events) - - - if @recordingWindowOpened - #@recordingWindow.close() - @closeRecordingWindow() - - this.trigger(details, backendRecordingId: backendRecordingId) - - onAbortedRecording: (details) -> - details.cause = 'aborted' - @events.push(["OnAbortedRecording"]) - details.events = @events - - augmentWithBackendRecordingId(@events) - - - if @recordingWindowOpened - #@recordingWindow.close() - @closeRecordingWindow() - - this.trigger(details) - - onOpenRecordingControls: () -> - logger.debug("recording controls opening") - if @recordingWindowOpened - #@recordingWindow.close() - @closeRecordingWindow() - - @popupRecordingControls() - - onRecordingControlsClosed: () -> - logger.debug("recording controls closed") - #@recordingWindow = null - @recordingWindowOpened = false - - onMixTransferred: () -> - @mixTransferred = true - - onAudioRecordingFormatChanged: (audioFormat) -> - logger.debug("_DEBUG_ onAudioRecordingFormatChanged", JSON.stringify(@recordingModel)) - this.trigger({audioRecordingFormat: audioFormat, isRecording: @recordingModel.isRecording()}) - - popupRecordingControls: () -> - logger.debug("poupRecordingControls") - #@recordingWindow = window.open("/popups/recording-controls", 'Recording', 'scrollbars=yes,toolbar=no,status=no,height=315,width=340') - #@recordingWindow.ParentRecordingStore = context.RecordingStore - #@recordingWindow.ParentIsRecording = @recordingModel.isRecording() - @app.layout.showDialog('session-recording', {}) - @recordingWindowOpened = true - - closeRecordingWindow: () -> - @app.layout.cancelDialog('session-recording'); - @recordingWindowOpened = false - } -) diff --git a/web/app/assets/javascripts/recordingModel.js b/web/app/assets/javascripts/recordingModel.js index e865300cf..6b593f58d 100644 --- a/web/app/assets/javascripts/recordingModel.js +++ b/web/app/assets/javascripts/recordingModel.js @@ -67,7 +67,6 @@ currentRecordingId = null; stoppingRecording = false; sessionId = _sessionId - context.RecordingActions.resetRecordingState() } @@ -140,7 +139,7 @@ console.log(`[RecordingState]: stopRecording userInitiated=${userInitiated} isRecordingOwner=${isRecordingOwner} reason=${reason} detail=${detail}`) if(stoppingRecording) { - logger.debug("ignoring stopRecording because we are already stopping"); + console.log("ignoring stopRecording because we are already stopping"); return; } stoppingRecording = true; @@ -159,7 +158,7 @@ var groupedTracks = groupTracksToClient(recording); //if(sessionModel.jamTracks() && isRecording()) { - // logger.debug("preemptive stop media") + // console.log("preemptive stop media") //context.jamClient.SessionStopPlay(); //} @@ -234,7 +233,7 @@ //alert("onServerStartRecording") var session = context.SessionStore.getCurrentOrLastSession(); if (!session) { - logger.debug("no session, so no recording"); + console.log("no session, so no recording"); return; } context.SessionStore.updateSessionInfo(session, true) @@ -245,7 +244,7 @@ var session = context.SessionStore.getCurrentOrLastSession(); if (!session) { - logger.debug("no session, so no recording"); + console.log("no session, so no recording"); return; } context.SessionStore.updateSessionInfo(session, true) @@ -253,7 +252,7 @@ getCurrentRecordingState().then(function (recordingState) { if (recordingState.isRecording && recordingState.recordingOwnerId === app.currentUserId) { // we are still recording, so don't transition to stopped - logger.debug("recording is still running, so don't transition to stopped"); + console.log("recording is still running, so don't transition to stopped"); return; } stopRecording(recordingId, null, null); @@ -308,6 +307,8 @@ } function handleRecordingStarted(recordingId, result, clientId) { + context.RecordingActions.resetRecordingState() + console.log("[RecordingState] handleRecordingStarted called", { recordingId, result, @@ -366,7 +367,7 @@ } function handleRecordingStopped(recordingId, result) { - console.log("[RecordingState] handleRecordingStopped") + console.log("[RecordingState] handleRecordingStopped event_id=" + recordingId + " current_id=" + currentRecordingId, result) var session = context.SessionStore.getCurrentOrLastSession(); if(session) { @@ -383,7 +384,6 @@ return; } - logger.debug("handleRecordingStopped " + recordingId, result) var success = result.success; var reason = result.reason; @@ -396,6 +396,13 @@ // the backend says the recording must be stopped. // tell the server to stop it too + if(recordingId == null || recordingId == "") { + // this occurs when you are told by the backend to stop; i.e., you are a non-creator of the + // recording. Stop, don't tell the server to stop; you aren't supposed to hve permission to + var details = {recordingId: recordingId, reason: reason, detail: detail, isRecording: false} + context.RecordingActions.stoppedRecording(details) + return; + } rest.stopRecording({ id: recordingId }) @@ -404,13 +411,13 @@ }) .fail(function(jqXHR, textStatus, errorMessage) { if(jqXHR.status == 422) { - logger.debug("recording already stopped %o", arguments); + console.log("recording already stopped %o", arguments); var details = {recordingId: recordingId, reason: reason, detail: detail, isRecording: false} $self.triggerHandler('stoppedRecording', details); context.RecordingActions.stoppedRecording(details) } else if(jqXHR.status == 404) { - logger.debug("recording is already deleted %o", arguments); + console.log("recording is already deleted %o", arguments); var details = {recordingId: recordingId, reason: reason, detail: detail, isRecording: false} $self.triggerHandler('stoppedRecording', details); context.RecordingActions.stoppedRecording(details) @@ -437,7 +444,7 @@ if (arguments.length == 2) { result = arguments[2] } - logger.debug("video recording aborted", result) + console.log("video recording aborted", result) context.JK.Banner.showAlert("Video has stopped recording. Audio is still recording.") //context.RecordingActions.stopRecording() @@ -498,6 +505,13 @@ /** * sync recording state with the client back end + * Describe exactly when we should fetch recording state from the server + * 1. If backend sends stopped/stopping/abort event + * 2. If track changes occurs + * 3. + * TOOD: describe exactly when we should fetch recording state from the client + * TODO: don't couple them into this one method + * */ async function getCurrentRecordingState() { var recording = null; diff --git a/web/app/assets/stylesheets/client/react-components/SessionScreen.scss b/web/app/assets/stylesheets/client/react-components/SessionScreen.scss index d9ee1f140..21eb119da 100644 --- a/web/app/assets/stylesheets/client/react-components/SessionScreen.scss +++ b/web/app/assets/stylesheets/client/react-components/SessionScreen.scss @@ -436,7 +436,7 @@ $session-screen-divider: 1190px; .session-recording-status { position:absolute; - width:500px; + width:700px; bottom:0; left:3px; max-height: 100%; /* Prevents growing outside the container */