Interface Fix for MS14314: Make use of original image filename when sharing

This commit is contained in:
Zach Fox 2018-06-11 17:10:09 -07:00
parent 6794fedf5b
commit 14034f29a1
2 changed files with 15 additions and 10 deletions

View file

@ -35,6 +35,7 @@ void SnapshotUploader::uploadSuccess(QNetworkReply& reply) {
QString thumbnailUrl = dataObject.value("thumbnail_url").toString(); QString thumbnailUrl = dataObject.value("thumbnail_url").toString();
QString imageUrl = dataObject.value("image_url").toString(); QString imageUrl = dataObject.value("image_url").toString();
QString snapshotID = dataObject.value("id").toString(); QString snapshotID = dataObject.value("id").toString();
QString originalImageFileName = dataObject.value("original_image_file_name").toString();
auto addressManager = DependencyManager::get<AddressManager>(); auto addressManager = DependencyManager::get<AddressManager>();
QString placeName = _inWorldLocation.authority(); // We currently only upload shareable places, in which case this is just host. QString placeName = _inWorldLocation.authority(); // We currently only upload shareable places, in which case this is just host.
QString currentPath = _inWorldLocation.path(); QString currentPath = _inWorldLocation.path();
@ -48,6 +49,7 @@ void SnapshotUploader::uploadSuccess(QNetworkReply& reply) {
detailsObject.insert("shareable_url", dataObject.value("shareable_url").toString()); detailsObject.insert("shareable_url", dataObject.value("shareable_url").toString());
} }
detailsObject.insert("snapshot_id", snapshotID); detailsObject.insert("snapshot_id", snapshotID);
detailsObject.insert("original_image_file_name", originalImageFileName);
QString pickledDetails = QJsonDocument(detailsObject).toJson(); QString pickledDetails = QJsonDocument(detailsObject).toJson();
userStoryObject.insert("details", pickledDetails); userStoryObject.insert("details", pickledDetails);
userStoryObject.insert("thumbnail_url", thumbnailUrl); userStoryObject.insert("thumbnail_url", thumbnailUrl);

View file

@ -37,8 +37,8 @@ var shareAfterLogin = false;
var snapshotToShareAfterLogin = []; var snapshotToShareAfterLogin = [];
var METAVERSE_BASE = Account.metaverseServerURL; var METAVERSE_BASE = Account.metaverseServerURL;
var isLoggedIn; var isLoggedIn;
var numGifSnapshotUploadsPending = 0; var mostRecentGifSnapshotFilename = "";
var numStillSnapshotUploadsPending = 0; var mostRecentStillSnapshotFilename = "";
// It's totally unnecessary to return to C++ to perform many of these requests, such as DELETEing an old story, // 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 // 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; return filePath.split('.').pop().toLowerCase() === extension;
} }
function getFilenameFromPath(str) {
return str.split('\\').pop().split('/').pop();
}
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.)
@ -147,9 +151,9 @@ function onMessage(message) {
print('Sharing snapshot with audience "for_url":', message.data); print('Sharing snapshot with audience "for_url":', message.data);
Window.shareSnapshot(message.data, Settings.getValue("previousSnapshotHref")); Window.shareSnapshot(message.data, Settings.getValue("previousSnapshotHref"));
if (isGif) { if (isGif) {
numGifSnapshotUploadsPending++; mostRecentGifSnapshotFilename = getFilenameFromPath(message.data);
} else { } else {
numStillSnapshotUploadsPending++; mostRecentStillSnapshotFilename = getFilenameFromPath(message.data);
} }
} else { } else {
shareAfterLogin = true; shareAfterLogin = true;
@ -383,15 +387,14 @@ function snapshotUploaded(isError, reply) {
isGif = fileExtensionMatches(imageURL, "gif"), isGif = fileExtensionMatches(imageURL, "gif"),
ignoreGifSnapshotData = false, ignoreGifSnapshotData = false,
ignoreStillSnapshotData = false; ignoreStillSnapshotData = false;
console.log("ZRF " + JSON.stringify(replyJson));
storyIDsToMaybeDelete.push(storyID); storyIDsToMaybeDelete.push(storyID);
if (isGif) { if (isGif) {
numGifSnapshotUploadsPending--; if (mostRecentGifSnapshotFilename !== replyJson.user_story.details.original_image_file_name) {
if (numGifSnapshotUploadsPending !== 0) {
ignoreGifSnapshotData = true; ignoreGifSnapshotData = true;
} }
} else { } else {
numStillSnapshotUploadsPending--; if (mostRecentStillSnapshotFilename !== replyJson.user_story.details.original_image_file_name) {
if (numStillSnapshotUploadsPending !== 0) {
ignoreStillSnapshotData = true; ignoreStillSnapshotData = true;
} }
} }
@ -686,9 +689,9 @@ function onUsernameChanged() {
Window.shareSnapshot(element.path, element.href); Window.shareSnapshot(element.path, element.href);
var isGif = fileExtensionMatches(element.path, "gif"); var isGif = fileExtensionMatches(element.path, "gif");
if (isGif) { if (isGif) {
numGifSnapshotUploadsPending++; mostRecentGifSnapshotFilename = getFilenameFromPath(element.path);
} else { } else {
numStillSnapshotUploadsPending++; mostRecentStillSnapshotFilename = getFilenameFromPath(element.path);
} }
}); });
} }