fixing state issues of front end recording

This commit is contained in:
Nuwan 2025-04-18 18:15:30 +05:30
parent fdb392f723
commit 911a37bec5
6 changed files with 52 additions and 53 deletions

View File

@ -11,7 +11,7 @@ AppStore = context.AppStore
onSessionMixerChange: (sessionMixers) ->
console.log("_DEBUG_* SessionRecordBtn onSessionMixerChange", sessionMixers.session)
@setState({isRecording: sessionMixers.session.isRecording})
@setState({isRecordingOwner: sessionMixers.session.recordingClinetId == @app.clientId})
@setState({isRecordingOwner: sessionMixers.session.recordingOwnerId && sessionMixers.session.recordingOwnerId == @app.currentUserId})
getInitialState: () ->
{childWindow: null, isRecording: false}

View File

@ -2,7 +2,7 @@ context = window
@SessionHelper = class SessionHelper
constructor: (app, session, participantsEverSeen, isRecording, downloadingJamTrack, preppingVstEnable, sessionRules, subscriptionRules, recordingClinetId) ->
constructor: (app, session, participantsEverSeen, isRecording, downloadingJamTrack, preppingVstEnable, sessionRules, subscriptionRules, recordingOwnerId) ->
@app = app
@session = session
@participantsEverSeen = participantsEverSeen
@ -12,7 +12,7 @@ context = window
@isLesson = @session?.lesson_session?
@sessionRules = sessionRules
@subscriptionRules = subscriptionRules
@recordingClinetId = recordingClinetId
@recordingOwnerId = recordingOwnerId
if @isLesson
@lessonId = @session.lesson_session.id

View File

@ -57,7 +57,7 @@ ConfigureTracksActions = @ConfigureTracksActions
@sessionUtils = context.JK.SessionUtils
@recordingModel = new context.JK.RecordingModel(@app, rest, context.jamClient);
RecordingActions.initModel(@recordingModel)
@helper = new context.SessionHelper(@app, @currentSession, @participantsEverSeen, @isRecording, @downloadingJamTrack, @enableVstTimeout?, @sessionRules, @subscriptionRules)
@helper = new context.SessionHelper(@app, @currentSession, @participantsEverSeen, @isRecording, @downloadingJamTrack, @enableVstTimeout?, @sessionRules, @subscriptionRules, @recordingOwnerId)
# onSessionJoinedByOther: (payload) ->
# clientId = payload.client_id
@ -95,7 +95,7 @@ ConfigureTracksActions = @ConfigureTracksActions
onVideoChanged: (@videoState) ->
issueChange: () ->
@helper = new context.SessionHelper(@app, @currentSession, @participantsEverSeen, @isRecording, @downloadingJamTrack, @enableVstTimeout?, @sessionRules, @subscriptionRules, @recordingClinetId)
@helper = new context.SessionHelper(@app, @currentSession, @participantsEverSeen, @isRecording, @downloadingJamTrack, @enableVstTimeout?, @sessionRules, @subscriptionRules, @recordingOwnerId)
this.trigger(@helper)
onWindowBackgrounded: () ->
@ -1820,11 +1820,11 @@ ConfigureTracksActions = @ConfigureTracksActions
this.recordingModel.getCurrentRecordingState().then((recordingState) => {
session = { ...session, ...recordingState };
//console.log("_DEBUG_* SessionStore#recordingState", recordingState);
logger.debug('update current session');
}).finally(() => {
//console.log("_DEBUG_* SessionStore#updateSessionInfo sessionState", session);
this.updateCurrentSession(session);
});
@ -1972,7 +1972,7 @@ ConfigureTracksActions = @ConfigureTracksActions
# @issueChange()
updateCurrentSession: `async function(sessionData) {
console.log("_DEBUG_* SessionStore#updateCurrentSession", sessionData)
//console.log("_DEBUG_* SessionStore#updateCurrentSession", sessionData)
if (sessionData !== null) {
let until_time;
this.currentOrLastSession = sessionData;
@ -2217,10 +2217,14 @@ ConfigureTracksActions = @ConfigureTracksActions
logger.debug("performLeaveSession: calling jamClient.LeaveSession for clientId=" + this.app.clientId);
logger.debug('before context.jamClient.LeaveSession')
await context.jamClient.LeaveSession({ sessionID: this.currentSessionId });
logger.debug('before leaveSessionRest')
this.leaveSessionRest(this.currentSessionId)
.done(function() {
session = this.getCurrentOrLastSession();
context.SessionStore.updateSessionInfo(session, true)
logger.debug('leaveSessionRest done')
deferred.resolve(arguments[0], arguments[1], arguments[2]);}.bind(this))
.fail(function() {

View File

@ -206,12 +206,13 @@
}
function onServerStartRecording() {
//alert("onServerStartRecording")
var session = context.SessionStore.getCurrentOrLastSession();
if (!session) {
logger.debug("no session, so no recording");
return;
}
context.SessionStore.updateSessionInfo(session)
context.SessionStore.updateSessionInfo(session, true)
}
function onServerStopRecording(recordingId) {
@ -221,7 +222,7 @@
logger.debug("no session, so no recording");
return;
}
context.SessionStore.updateSessionInfo(session)
context.SessionStore.updateSessionInfo(session, true)
getCurrentRecordingState().then(function (recordingState) {
if (recordingState.isRecording && recordingState.recordingOwnerId === app.currentUserId) {
@ -234,8 +235,7 @@
}
async function handleRecordingStartResult(recordingId, result) {
//console.log("_DEBUG_* handleRecordingStartResult", recordingId, result)
function handleRecordingStartResult(recordingId, result) {
var success = result.success;
var reason = result.reason;
var detail = result.detail
@ -255,7 +255,6 @@
}
function handleRecordingStopResult(recordingId, result) {
//console.log("_DEBUG_* handleRecordingStopResult", recordingId, result)
var success = result.success;
var reason = result.reason;
var detail = result.detail;
@ -275,7 +274,6 @@
}
function handleRecordingStarted(recordingId, result, clientId) {
console.log("_DEBUG_* handleRecordingStarted", recordingId, result)
var success = result.success;
var reason = result.reason;
var detail = result.detail;
@ -302,20 +300,11 @@
context.RecordingActions.startedRecording(details)
}
async function handleRecordingStopped(recordingId, result) {
console.log("_DEBUG_* handleRecordingStopped", recordingId, result, $self)
// var recordState = await $self.getRecordingState();
// console.log("_DEBUG_* handleRecordingStopped -> recordState", recordState);
var session;
try{
session = context.SessionStore.getCurrentOrLastSession();
}catch(e){
console.error("_DEBUG_* Error getting session", e);
}
function handleRecordingStopped(recordingId, result) {
var session = context.SessionStore.getCurrentOrLastSession();
console.log("_DEBUG_* handleRecordingStopped -> session", session);
if(session) {
context.SessionStore.updateSessionInfo(session)
context.SessionStore.updateSessionInfo(session, true)
}
// if(recordState.isRecording) {
@ -374,7 +363,6 @@
}
function handleRecordingAborted(recordingId, result) {
//console.log("_DEBUG_* handleRecordingAborted", recordingId, result)
if(recordingId == "video") {
// comes from AbortedVideoRecording
@ -444,34 +432,40 @@
/**
* sync recording state with the client back end
*/
async function getRecordingState() {
var isRecording = false;
var recordingClientId = null;
var currentRecId = await jamClient.GetCurrentRecordingId(); //if this passes recording Id it means there is an ongoing recording
//var currentRecId = currentRecordingId
console.log("_DEBUG_* getRecordingState", currentRecId)
if(currentRecId && currentRecId !== '') {
var recording = await rest.getRecordingPromise({id: currentRecId})
if(recording) {
isRecording = true;
recordingClientId = recording.client_id;
}
} else {
isRecording = false;
recordingClientId = null;
}
return { isRecording: isRecording, recordingClientId: recordingClientId };
}
// async function getRecordingState() {
// var isRecording = false;
// var recordingClientId = null;
// var currentRecId = await jamClient.GetCurrentRecordingId(); //if this passes recording Id it means there is an ongoing recording
// //var currentRecId = currentRecordingId
// console.log("_DEBUG_* getRecordingState", currentRecId)
// if(currentRecId && currentRecId !== '') {
// var recording = await rest.getRecordingPromise({id: currentRecId})
// if(recording) {
// isRecording = true;
// recordingClientId = recording.client_id;
// }
// } else {
// isRecording = false;
// recordingClientId = null;
// }
// return { isRecording: isRecording, recordingClientId: recordingClientId };
// }
async function getCurrentRecordingState() {
var recording = null;
var session = context.SessionStore.getCurrentOrLastSession();
if (!session) {
logger.debug("no session, so no recording");
return { isRecording: false, recordingOwnerId: null };
}
var recordingId = await context.jamClient.GetCurrentRecordingId();
if (recordingId && recordingId != "") {
var isRecording = recordingId && recordingId != "";
if (isRecording) {
recording = await rest.getRecordingPromise({ id: recordingId })
}
return {
isRecording: recording !== null,
recordingOwnerId: recording ? recording.owner.id : null,
isRecording: isRecording,
recordingOwnerId: isRecording && recording ? recording.owner.id : null,
}
}
@ -509,7 +503,7 @@
return;
}
context.SessionStore.updateSessionInfo(session)
context.SessionStore.updateSessionInfo(session, true)
getCurrentRecordingState().then(function (recordingState) {
if (recordingState.isRecording) {
@ -583,7 +577,7 @@
this.reset = reset;
this.stopRecordingIfNeeded = stopRecordingIfNeeded;
this.currentOrLastRecordingId = function () { return currentOrLastRecordingId; };
this.getRecordingState = getRecordingState;
//this.getRecordingState = getRecordingState;
this.getCurrentRecordingState = getCurrentRecordingState;

View File

@ -409,7 +409,7 @@
// you should only update currentSession with this function
function updateCurrentSession(sessionData) {
console.log("_DEBUG_* sessionModel#updateCurrentSession", sessionData)
//console.log("_DEBUG_* sessionModel#updateCurrentSession", sessionData)
if(sessionData != null) {
currentOrLastSession = sessionData;
}
@ -429,7 +429,7 @@
}
function updateSessionInfo(response, callback, force) {
console.log("_DEBUG_* sessionModel#updateSessionInfo", response)
//console.log("_DEBUG_* sessionModel#updateSessionInfo", response)
if(force === true || currentTrackChanges < response.track_changes_counter) {
logger.debug("updating current track changes from %o to %o", currentTrackChanges, response.track_changes_counter)
currentTrackChanges = response.track_changes_counter;

View File

@ -275,7 +275,8 @@
}
//}
// if the session is already recording, we need to start recording
// if the session is already recording, we need to call the follwing to know the recording state
// and to update the recording state in the UI
context.RecordingStore.recordingModel.onServerStartRecording();
});
}