Fix race condition with images

pull/1/head
yflory 5 years ago
parent 50a039b40b
commit 663fa9b474

@ -356,7 +356,6 @@ define([
sframeChan.on('EV_OO_EVENT', function (obj) { sframeChan.on('EV_OO_EVENT', function (obj) {
switch (obj.ev) { switch (obj.ev) {
case 'READY': case 'READY':
rtChannel.ready = true;
break; break;
case 'LEAVE': case 'LEAVE':
removeClient(obj.data); removeClient(obj.data);
@ -505,8 +504,8 @@ define([
buildVersion: "5.2.6", buildVersion: "5.2.6",
buildNumber: 2, buildNumber: 2,
licenseType: 3, licenseType: 3,
"g_cAscSpellCheckUrl": "/spellchecker", //"g_cAscSpellCheckUrl": "/spellchecker",
"settings":{"spellcheckerUrl":"/spellchecker","reconnection":{"attempts":50,"delay":2000}} //"settings":{"spellcheckerUrl":"/spellchecker","reconnection":{"attempts":50,"delay":2000}}
}); });
// Open the document // Open the document
send({ send({
@ -648,7 +647,18 @@ define([
send({ type: "message" }); send({ type: "message" });
break; break;
case "saveChanges": case "saveChanges":
// We're sending our changes to netflux
handleChanges(obj, send); handleChanges(obj, send);
try {
var docs = window.frames[0].AscCommon.g_oDocumentUrls.urls || {};
var mediasSources = getMediasSources();
Object.keys(mediasSources).forEach(function (name) {
if (!docs['media/'+name]) {
delete mediasSources[name];
}
});
APP.onLocal();
} catch (e) {}
break; break;
case "unLockDocument": case "unLockDocument":
if (obj.releaseLocks && content.locks && content.locks[getId()]) { if (obj.releaseLocks && content.locks && content.locks[getId()]) {
@ -746,12 +756,15 @@ define([
// Add image to the list // Add image to the list
var mediasSources = getMediasSources(); var mediasSources = getMediasSources();
mediasSources[name] = data; mediasSources[name] = data;
APP.onLocal();
APP.getImageURL(name, function(url) {
debug("CRYPTPAD success add " + name); APP.realtime.onSettle(function () {
APP.AddImageSuccessCallback({ APP.getImageURL(name, function(url) {
name: name, debug("CRYPTPAD success add " + name);
url: url APP.AddImageSuccessCallback({
name: name,
url: url
});
}); });
}); });
} }

Loading…
Cancel
Save