mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 17:02:57 +02:00
Fix case when user stories would be incorrectly deleted
This commit is contained in:
parent
9a4b624029
commit
aa0394c2ef
2 changed files with 29 additions and 10 deletions
|
@ -359,7 +359,7 @@ function showUploadingMessage(selectedID, destination) {
|
||||||
shareBarHelp.classList.add("uploading");
|
shareBarHelp.classList.add("uploading");
|
||||||
shareBarHelp.setAttribute("data-destination", destination);
|
shareBarHelp.setAttribute("data-destination", destination);
|
||||||
}
|
}
|
||||||
function hideUploadingMessageAndShare(selectedID, storyID) {
|
function hideUploadingMessageAndMaybeShare(selectedID, storyID) {
|
||||||
if (selectedID.id) {
|
if (selectedID.id) {
|
||||||
selectedID = selectedID.id; // sometimes (?), `containerID` is passed as an HTML object to these functions; we just want the ID
|
selectedID = selectedID.id; // sometimes (?), `containerID` is passed as an HTML object to these functions; we just want the ID
|
||||||
}
|
}
|
||||||
|
@ -382,21 +382,28 @@ function hideUploadingMessageAndShare(selectedID, storyID) {
|
||||||
var facebookButton = document.getElementById(selectedID + "facebookButton");
|
var facebookButton = document.getElementById(selectedID + "facebookButton");
|
||||||
window.open(facebookButton.getAttribute("href"), "_blank");
|
window.open(facebookButton.getAttribute("href"), "_blank");
|
||||||
shareBarHelp.innerHTML = facebookShareText;
|
shareBarHelp.innerHTML = facebookShareText;
|
||||||
|
// This emitWebEvent() call isn't necessary in the "hifi" and "blast" cases
|
||||||
|
// because the "removeFromStoryIDsToMaybeDelete()" call happens
|
||||||
|
// in snapshot.js when sharing with that method.
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: "snapshot",
|
||||||
|
action: "removeFromStoryIDsToMaybeDelete",
|
||||||
|
story_id: storyID
|
||||||
|
}));
|
||||||
break;
|
break;
|
||||||
case 'twitter':
|
case 'twitter':
|
||||||
var twitterButton = document.getElementById(selectedID + "twitterButton");
|
var twitterButton = document.getElementById(selectedID + "twitterButton");
|
||||||
window.open(twitterButton.getAttribute("href"), "_blank");
|
window.open(twitterButton.getAttribute("href"), "_blank");
|
||||||
shareBarHelp.innerHTML = twitterShareText;
|
shareBarHelp.innerHTML = twitterShareText;
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: "snapshot",
|
||||||
|
action: "removeFromStoryIDsToMaybeDelete",
|
||||||
|
story_id: storyID
|
||||||
|
}));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
shareBarHelp.setAttribute("data-destination", "");
|
shareBarHelp.setAttribute("data-destination", "");
|
||||||
|
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
|
||||||
type: "snapshot",
|
|
||||||
action: "removeFromStoryIDsToMaybeDelete",
|
|
||||||
story_id: storyID
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function updateShareInfo(containerID, storyID) {
|
function updateShareInfo(containerID, storyID) {
|
||||||
|
@ -417,7 +424,7 @@ function updateShareInfo(containerID, storyID) {
|
||||||
twitterButton.setAttribute("target", "_blank");
|
twitterButton.setAttribute("target", "_blank");
|
||||||
twitterButton.setAttribute("href", 'https://twitter.com/intent/tweet?text=I%20just%20took%20a%20snapshot!&url=' + shareURL + '&via=highfidelityinc&hashtags=VR,HiFi');
|
twitterButton.setAttribute("href", 'https://twitter.com/intent/tweet?text=I%20just%20took%20a%20snapshot!&url=' + shareURL + '&via=highfidelityinc&hashtags=VR,HiFi');
|
||||||
|
|
||||||
hideUploadingMessageAndShare(containerID, storyID);
|
hideUploadingMessageAndMaybeShare(containerID, storyID);
|
||||||
}
|
}
|
||||||
function blastToConnections(selectedID, isGif) {
|
function blastToConnections(selectedID, isGif) {
|
||||||
if (selectedID.id) {
|
if (selectedID.id) {
|
||||||
|
@ -552,6 +559,12 @@ function shareButtonClicked(destination, selectedID) {
|
||||||
|
|
||||||
if (!storyID) {
|
if (!storyID) {
|
||||||
showUploadingMessage(selectedID, destination);
|
showUploadingMessage(selectedID, destination);
|
||||||
|
} else {
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: "snapshot",
|
||||||
|
action: "removeFromStoryIDsToMaybeDelete",
|
||||||
|
story_id: storyID
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,11 @@ function openLoginWindow() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function removeFromStoryIDsToMaybeDelete(story_id) {
|
||||||
|
storyIDsToMaybeDelete.splice(storyIDsToMaybeDelete.indexOf(story_id), 1);
|
||||||
|
print('storyIDsToMaybeDelete[] now:', JSON.stringify(storyIDsToMaybeDelete));
|
||||||
|
}
|
||||||
|
|
||||||
function onMessage(message) {
|
function onMessage(message) {
|
||||||
// Receives message from the html dialog via the qwebchannel EventBridge. This is complicated by the following:
|
// Receives message from the html dialog via the qwebchannel EventBridge. This is complicated by the following:
|
||||||
// 1. Although we can send POJOs, we cannot receive a toplevel object. (Arrays of POJOs are fine, though.)
|
// 1. Although we can send POJOs, we cannot receive a toplevel object. (Arrays of POJOs are fine, though.)
|
||||||
|
@ -191,6 +196,7 @@ function onMessage(message) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
print("SUCCESS uploading announcement story! Story ID:", response.user_story.id);
|
print("SUCCESS uploading announcement story! Story ID:", response.user_story.id);
|
||||||
|
removeFromStoryIDsToMaybeDelete(message.story_id); // Don't delete original "for_url" story
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -230,13 +236,13 @@ function onMessage(message) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
print("SUCCESS changing audience" + (message.isAnnouncement ? " and posting announcement!" : "!"));
|
print("SUCCESS changing audience" + (message.isAnnouncement ? " and posting announcement!" : "!"));
|
||||||
|
removeFromStoryIDsToMaybeDelete(message.story_id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'removeFromStoryIDsToMaybeDelete':
|
case 'removeFromStoryIDsToMaybeDelete':
|
||||||
storyIDsToMaybeDelete.splice(storyIDsToMaybeDelete.indexOf(message.story_id), 1);
|
removeFromStoryIDsToMaybeDelete(message.story_id);
|
||||||
print('storyIDsToMaybeDelete[] now:', JSON.stringify(storyIDsToMaybeDelete));
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print('Unknown message action received by snapshot.js!');
|
print('Unknown message action received by snapshot.js!');
|
||||||
|
|
Loading…
Reference in a new issue