Commit 3376f66b by Kim Peace

Fixed to use promise instead of callback parameter

parent 4d19a6c1
......@@ -171,7 +171,7 @@ FermiWebSocketMessageHandler.captureRequest = function (data) {
if ($("#recordBtn .record").hasClass("disable")) {
screenLock();
recordStop(function () {
recordStop().then(function () {
$("#screenLock").remove();
captureAndShareImage(
serverInfo.cmsURL + "/chatapi/file/uploadArchive",
......@@ -222,7 +222,7 @@ FermiWebSocketMessageHandler.pipEndRequest = function () {
FermiWebSocketMessageHandler.apiSendOwnerChangeComplete = function (data) {
penOff();
if ($("#recordBtn .record").hasClass("disable")) {
recordStop(function () {});
recordStop();
}
if ($("#micBtn .voice").hasClass("disable")) {
micOff();
......
......@@ -28,7 +28,7 @@ function toggleEraser() {
function toggleCapture() {
if ($("#recordBtn").hasClass("bg_red")) {
screenLock();
recordStop(function () {
recordStop().then(function () {
$("#screenLock").remove();
coview_api.Capture(serverInfo.cmsURL + "/chatapi/file/uploadArchive");
});
......@@ -79,15 +79,16 @@ function toggleRecord() {
if (!$("#recordBtn .record").hasClass("disable")) {
recordStart();
} else {
recordStop(function () {
recordStop().then(function () {
console.info("Did record stop");
});
}
}
function recordStop(callback) {
function recordStop() {
return new Promise(function (done) {
if (!$("#recordBtn .record").hasClass("disable")) {
callback();
done();
return;
}
Common.showLoadingIndicator();
......@@ -95,14 +96,13 @@ function recordStop(callback) {
screenLock();
// アーカイブ保存処理
mainManRecordWithCollaboration(
"stop",
serverInfo.cmsURL + "/chatapi/file/uploadArchive",
callback
);
mainManRecordStopWithCollaboration().then(function () {
done();
});
});
}
async function sendRecordedData(url, callback) {
async function sendRecordedData() {
return new Promise(function (done) {
// get lastest message id and update message from server via native
const blob = new Blob(recordedBlobs, { type: "video/webm" });
......@@ -118,41 +118,45 @@ async function sendRecordedData(url, callback) {
: ARCHIVE_TYPE.VOICE;
formData.append("archiveType", collaborationType);
postRecords(url, formData, function () {
postRecords(formData).then(function () {
done();
callback();
});
});
}
function mainManRecordWithCollaboration(action, url, callback) {
function mainManRecordStopWithCollaboration() {
return new Promise(function (done) {
try {
mediaRecorder.stop();
} catch (exeption) {
console.error("Record failed");
callback();
console.error("Record stop failed");
done();
}
sendRecordedData(url, callback);
sendRecordedData().then(function () {
done();
});
});
}
function postRecords(url, formData, callback) {
function postRecords(formData) {
return new Promise(function (done) {
$.ajax({
type: "post",
url: url,
url: serverInfo.cmsURL + "/chatapi/file/uploadArchive",
data: formData,
contentType: false,
processData: false,
success: function (res) {
recordFinished();
Common.dismissLoadingIndicator();
callback();
done();
},
error: function (err) {
recordFinished();
Common.dismissLoadingIndicator();
callback();
},
});
});
}
// div削除関数
......
......@@ -510,7 +510,9 @@ CoviewBridge.exitCollaboration = function () {
}
if ($("#recordBtn .record").hasClass("disable")) {
recordStop(CoviewBridge.finishCollaboration);
recordStop().then(function () {
CoviewBridge.finishCollaboration();
});
} else {
CoviewBridge.finishCollaboration();
}
......
......@@ -28,7 +28,7 @@ document.addEventListener("DOMContentLoaded", function () {
// call from collaboration_overlay_menu.html and collaboration.html
function changeCollaboration(collaborationType) {
recordStop(function () {
recordStop().then(function () {
var newMeetingID = 0;
if (globalUserInfo.collaborationType == COLLABORATION_TYPE.DOCUMENT) {
NativeBridgeDelegate.exitMeetingRoom();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment