diff --git a/interface/src/ui/SnapshotUploader.cpp b/interface/src/ui/SnapshotUploader.cpp index 67902c1a35..4613871d25 100644 --- a/interface/src/ui/SnapshotUploader.cpp +++ b/interface/src/ui/SnapshotUploader.cpp @@ -35,6 +35,7 @@ void SnapshotUploader::uploadSuccess(QNetworkReply& reply) { QString thumbnailUrl = dataObject.value("thumbnail_url").toString(); QString imageUrl = dataObject.value("image_url").toString(); QString snapshotID = dataObject.value("id").toString(); + QString originalImageFileName = dataObject.value("original_image_file_name").toString(); auto addressManager = DependencyManager::get(); QString placeName = _inWorldLocation.authority(); // We currently only upload shareable places, in which case this is just host. QString currentPath = _inWorldLocation.path(); @@ -48,6 +49,7 @@ void SnapshotUploader::uploadSuccess(QNetworkReply& reply) { detailsObject.insert("shareable_url", dataObject.value("shareable_url").toString()); } detailsObject.insert("snapshot_id", snapshotID); + detailsObject.insert("original_image_file_name", originalImageFileName); QString pickledDetails = QJsonDocument(detailsObject).toJson(); userStoryObject.insert("details", pickledDetails); userStoryObject.insert("thumbnail_url", thumbnailUrl); diff --git a/scripts/system/snapshot.js b/scripts/system/snapshot.js index f7e590c6f9..9b540aefc8 100644 --- a/scripts/system/snapshot.js +++ b/scripts/system/snapshot.js @@ -37,8 +37,8 @@ var shareAfterLogin = false; var snapshotToShareAfterLogin = []; var METAVERSE_BASE = Account.metaverseServerURL; var isLoggedIn; -var numGifSnapshotUploadsPending = 0; -var numStillSnapshotUploadsPending = 0; +var mostRecentGifSnapshotFilename = ""; +var mostRecentStillSnapshotFilename = ""; // It's totally unnecessary to return to C++ to perform many of these requests, such as DELETEing an old story, // POSTING a new one, PUTTING a new audience, or GETTING story data. It's far more efficient to do all of that within JS @@ -64,6 +64,10 @@ function fileExtensionMatches(filePath, extension) { return filePath.split('.').pop().toLowerCase() === extension; } +function getFilenameFromPath(str) { + return str.split('\\').pop().split('/').pop(); +} + function onMessage(message) { // 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.) @@ -147,9 +151,9 @@ function onMessage(message) { print('Sharing snapshot with audience "for_url":', message.data); Window.shareSnapshot(message.data, Settings.getValue("previousSnapshotHref")); if (isGif) { - numGifSnapshotUploadsPending++; + mostRecentGifSnapshotFilename = getFilenameFromPath(message.data); } else { - numStillSnapshotUploadsPending++; + mostRecentStillSnapshotFilename = getFilenameFromPath(message.data); } } else { shareAfterLogin = true; @@ -385,13 +389,11 @@ function snapshotUploaded(isError, reply) { ignoreStillSnapshotData = false; storyIDsToMaybeDelete.push(storyID); if (isGif) { - numGifSnapshotUploadsPending--; - if (numGifSnapshotUploadsPending !== 0) { + if (mostRecentGifSnapshotFilename !== replyJson.user_story.details.original_image_file_name) { ignoreGifSnapshotData = true; } } else { - numStillSnapshotUploadsPending--; - if (numStillSnapshotUploadsPending !== 0) { + if (mostRecentStillSnapshotFilename !== replyJson.user_story.details.original_image_file_name) { ignoreStillSnapshotData = true; } } @@ -686,9 +688,9 @@ function onUsernameChanged() { Window.shareSnapshot(element.path, element.href); var isGif = fileExtensionMatches(element.path, "gif"); if (isGif) { - numGifSnapshotUploadsPending++; + mostRecentGifSnapshotFilename = getFilenameFromPath(element.path); } else { - numStillSnapshotUploadsPending++; + mostRecentStillSnapshotFilename = getFilenameFromPath(element.path); } }); }