mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Merge branch 'master' of github.com:highfidelity/hifi into head-controller
This commit is contained in:
commit
10ddbecdb9
3 changed files with 68 additions and 25 deletions
|
@ -388,8 +388,13 @@ Rectangle {
|
|||
sortIndicatorColumn: settings.nearbySortIndicatorColumn;
|
||||
sortIndicatorOrder: settings.nearbySortIndicatorOrder;
|
||||
onSortIndicatorColumnChanged: {
|
||||
settings.nearbySortIndicatorColumn = sortIndicatorColumn;
|
||||
sortModel();
|
||||
if (sortIndicatorColumn > 2) {
|
||||
// these are not sortable, switch back to last column
|
||||
sortIndicatorColumn = settings.nearbySortIndicatorColumn;
|
||||
} else {
|
||||
settings.nearbySortIndicatorColumn = sortIndicatorColumn;
|
||||
sortModel();
|
||||
}
|
||||
}
|
||||
onSortIndicatorOrderChanged: {
|
||||
settings.nearbySortIndicatorOrder = sortIndicatorOrder;
|
||||
|
|
|
@ -21,6 +21,11 @@ var blastShareText = "Blast to my Connections",
|
|||
hifiAlreadySharedText = "Already Shared to Snaps Feed",
|
||||
facebookShareText = "Share to Facebook",
|
||||
twitterShareText = "Share to Twitter";
|
||||
|
||||
function fileExtensionMatches(filePath, extension) {
|
||||
return filePath.split('.').pop().toLowerCase() === extension;
|
||||
}
|
||||
|
||||
function showSetupInstructions() {
|
||||
var snapshotImagesDiv = document.getElementById("snapshot-images");
|
||||
snapshotImagesDiv.className = "snapshotInstructions";
|
||||
|
@ -276,10 +281,10 @@ function addImage(image_data, isLoggedIn, canShare, isGifLoading, isShowingPrevi
|
|||
if (!image_data.localPath) {
|
||||
return;
|
||||
}
|
||||
var id = "p" + (idCounter++),
|
||||
imageContainer = document.createElement("DIV"),
|
||||
var imageContainer = document.createElement("DIV"),
|
||||
img = document.createElement("IMG"),
|
||||
isGif;
|
||||
isGif = fileExtensionMatches(image_data.localPath, "gif"),
|
||||
id = "p" + (isGif ? "1" : "0");
|
||||
imageContainer.id = id;
|
||||
imageContainer.style.width = "95%";
|
||||
imageContainer.style.height = "240px";
|
||||
|
@ -290,18 +295,17 @@ function addImage(image_data, isLoggedIn, canShare, isGifLoading, isShowingPrevi
|
|||
imageContainer.style.position = "relative";
|
||||
img.id = id + "img";
|
||||
img.src = image_data.localPath;
|
||||
isGif = img.src.split('.').pop().toLowerCase() === "gif";
|
||||
imageContainer.appendChild(img);
|
||||
document.getElementById("snapshot-images").appendChild(imageContainer);
|
||||
paths.push(image_data.localPath);
|
||||
img.onload = function () {
|
||||
paths.push(image_data.localPath);
|
||||
if (isGif) {
|
||||
imageContainer.innerHTML += '<span class="gifLabel">GIF</span>';
|
||||
}
|
||||
if (!isGifLoading) {
|
||||
appendShareBar(id, isLoggedIn, canShare, isGif, blastButtonDisabled, hifiButtonDisabled, canBlast);
|
||||
}
|
||||
if (!isGifLoading || (isShowingPreviousImages && !image_data.story_id)) {
|
||||
if ((!isShowingPreviousImages && ((isGif && !isGifLoading) || !isGif)) || (isShowingPreviousImages && !image_data.story_id)) {
|
||||
shareForUrl(id);
|
||||
}
|
||||
if (isShowingPreviousImages && isLoggedIn && image_data.story_id) {
|
||||
|
@ -638,9 +642,8 @@ window.onload = function () {
|
|||
// The last element of the message contents list contains a bunch of options,
|
||||
// including whether or not we can share stuff
|
||||
// The other elements of the list contain image paths.
|
||||
|
||||
if (messageOptions.containsGif) {
|
||||
if (messageOptions.processingGif) {
|
||||
if (messageOptions.containsGif === true) {
|
||||
if (messageOptions.processingGif === true) {
|
||||
imageCount = message.image_data.length + 1; // "+1" for the GIF that'll finish processing soon
|
||||
message.image_data.push({ localPath: messageOptions.loadingGifPath });
|
||||
message.image_data.forEach(function (element, idx) {
|
||||
|
@ -669,7 +672,7 @@ window.onload = function () {
|
|||
handleCaptureSetting(message.setting);
|
||||
break;
|
||||
case 'snapshotUploadComplete':
|
||||
var isGif = message.image_url.split('.').pop().toLowerCase() === "gif";
|
||||
var isGif = fileExtensionMatches(message.image_url, "gif");
|
||||
updateShareInfo(isGif ? "p1" : "p0", message.story_id);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -36,6 +36,8 @@ var shareAfterLogin = false;
|
|||
var snapshotToShareAfterLogin = [];
|
||||
var METAVERSE_BASE = location.metaverseServerUrl;
|
||||
var isLoggedIn;
|
||||
var numGifSnapshotUploadsPending = 0;
|
||||
var numStillSnapshotUploadsPending = 0;
|
||||
|
||||
// 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
|
||||
|
@ -56,6 +58,10 @@ function removeFromStoryIDsToMaybeDelete(story_id) {
|
|||
print('storyIDsToMaybeDelete[] now:', JSON.stringify(storyIDsToMaybeDelete));
|
||||
}
|
||||
|
||||
function fileExtensionMatches(filePath, extension) {
|
||||
return filePath.split('.').pop().toLowerCase() === extension;
|
||||
}
|
||||
|
||||
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.)
|
||||
|
@ -139,6 +145,12 @@ function onMessage(message) {
|
|||
if (isLoggedIn) {
|
||||
print('Sharing snapshot with audience "for_url":', message.data);
|
||||
Window.shareSnapshot(message.data, Settings.getValue("previousSnapshotHref"));
|
||||
var isGif = fileExtensionMatches(message.data, "gif");
|
||||
if (isGif) {
|
||||
numGifSnapshotUploadsPending++;
|
||||
} else {
|
||||
numStillSnapshotUploadsPending++;
|
||||
}
|
||||
} else {
|
||||
shareAfterLogin = true;
|
||||
snapshotToShareAfterLogin.push({ path: message.data, href: Settings.getValue("previousSnapshotHref") });
|
||||
|
@ -307,22 +319,39 @@ function onButtonClicked() {
|
|||
|
||||
function snapshotUploaded(isError, reply) {
|
||||
if (!isError) {
|
||||
var replyJson = JSON.parse(reply);
|
||||
var storyID = replyJson.user_story.id;
|
||||
var replyJson = JSON.parse(reply),
|
||||
storyID = replyJson.user_story.id,
|
||||
imageURL = replyJson.user_story.details.image_url,
|
||||
isGif = fileExtensionMatches(imageURL, "gif"),
|
||||
ignoreGifSnapshotData = false,
|
||||
ignoreStillSnapshotData = false;
|
||||
storyIDsToMaybeDelete.push(storyID);
|
||||
var imageURL = replyJson.user_story.details.image_url;
|
||||
var isGif = imageURL.split('.').pop().toLowerCase() === "gif";
|
||||
print('SUCCESS: Snapshot uploaded! Story with audience:for_url created! ID:', storyID);
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
type: "snapshot",
|
||||
action: "snapshotUploadComplete",
|
||||
story_id: storyID,
|
||||
image_url: imageURL,
|
||||
}));
|
||||
if (isGif) {
|
||||
Settings.setValue("previousAnimatedSnapStoryID", storyID);
|
||||
numGifSnapshotUploadsPending--;
|
||||
if (numGifSnapshotUploadsPending !== 0) {
|
||||
ignoreGifSnapshotData = true;
|
||||
}
|
||||
} else {
|
||||
Settings.setValue("previousStillSnapStoryID", storyID);
|
||||
numStillSnapshotUploadsPending--;
|
||||
if (numStillSnapshotUploadsPending !== 0) {
|
||||
ignoreStillSnapshotData = true;
|
||||
}
|
||||
}
|
||||
if ((isGif && !ignoreGifSnapshotData) || (!isGif && !ignoreStillSnapshotData)) {
|
||||
print('SUCCESS: Snapshot uploaded! Story with audience:for_url created! ID:', storyID);
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
type: "snapshot",
|
||||
action: "snapshotUploadComplete",
|
||||
story_id: storyID,
|
||||
image_url: imageURL,
|
||||
}));
|
||||
if (isGif) {
|
||||
Settings.setValue("previousAnimatedSnapStoryID", storyID);
|
||||
} else {
|
||||
Settings.setValue("previousStillSnapStoryID", storyID);
|
||||
}
|
||||
} else {
|
||||
print('Ignoring snapshotUploaded() callback for stale ' + (isGif ? 'GIF' : 'Still' ) + ' snapshot. Stale story ID:', storyID);
|
||||
}
|
||||
} else {
|
||||
print(reply);
|
||||
|
@ -568,6 +597,12 @@ function onUsernameChanged() {
|
|||
snapshotToShareAfterLogin.forEach(function (element) {
|
||||
print('Uploading snapshot after login:', element.path);
|
||||
Window.shareSnapshot(element.path, element.href);
|
||||
var isGif = fileExtensionMatches(element.path, "gif");
|
||||
if (isGif) {
|
||||
numGifSnapshotUploadsPending++;
|
||||
} else {
|
||||
numStillSnapshotUploadsPending++;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue