mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-10 06:31:01 +02:00
Add announcements support
This commit is contained in:
parent
f838e87f48
commit
e1789996fb
2 changed files with 40 additions and 16 deletions
|
@ -23,7 +23,7 @@ function clearImages() {
|
||||||
imageCount = 0;
|
imageCount = 0;
|
||||||
idCounter = 0;
|
idCounter = 0;
|
||||||
}
|
}
|
||||||
function addImage(image_data, isGifLoading, isShowingPreviousImages, canSharePreviousImages) {
|
function addImage(image_data, isGifLoading, isShowingPreviousImages, canSharePreviousImages, hifiShareButtonsDisabled) {
|
||||||
if (!image_data.localPath) {
|
if (!image_data.localPath) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -49,19 +49,19 @@ function addImage(image_data, isGifLoading, isShowingPreviousImages, canSharePre
|
||||||
if (!isGifLoading && !isShowingPreviousImages) {
|
if (!isGifLoading && !isShowingPreviousImages) {
|
||||||
shareForUrl(id);
|
shareForUrl(id);
|
||||||
} else if (isShowingPreviousImages && canSharePreviousImages) {
|
} else if (isShowingPreviousImages && canSharePreviousImages) {
|
||||||
appendShareBar(id, image_data.story_id, isGif)
|
appendShareBar(id, image_data.story_id, isGif, hifiShareButtonsDisabled)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function appendShareBar(divID, story_id, isGif) {
|
function appendShareBar(divID, story_id, isGif, hifiShareButtonsDisabled) {
|
||||||
var story_url = "https://highfidelity.com/user_stories/" + story_id;
|
var story_url = "https://highfidelity.com/user_stories/" + story_id;
|
||||||
var parentDiv = document.getElementById(divID);
|
var parentDiv = document.getElementById(divID);
|
||||||
parentDiv.setAttribute('data-story-id', story_id);
|
parentDiv.setAttribute('data-story-id', story_id);
|
||||||
document.getElementById(divID).appendChild(createShareOverlay(divID, isGif, story_url));
|
document.getElementById(divID).appendChild(createShareOverlay(divID, isGif, story_url, hifiShareButtonsDisabled));
|
||||||
twttr.events.bind('click', function (event) {
|
twttr.events.bind('click', function (event) {
|
||||||
shareButtonClicked(divID);
|
shareButtonClicked(divID);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function createShareOverlay(parentID, isGif, shareURL) {
|
function createShareOverlay(parentID, isGif, shareURL, hifiShareButtonsDisabled) {
|
||||||
var shareOverlayContainer = document.createElement("DIV");
|
var shareOverlayContainer = document.createElement("DIV");
|
||||||
shareOverlayContainer.id = parentID + "shareOverlayContainer";
|
shareOverlayContainer.id = parentID + "shareOverlayContainer";
|
||||||
shareOverlayContainer.style.position = "absolute";
|
shareOverlayContainer.style.position = "absolute";
|
||||||
|
@ -115,8 +115,8 @@ function createShareOverlay(parentID, isGif, shareURL) {
|
||||||
'<br/>' +
|
'<br/>' +
|
||||||
'<div class="shareControls">' +
|
'<div class="shareControls">' +
|
||||||
'<div class="hifiShareControls">' +
|
'<div class="hifiShareControls">' +
|
||||||
'<input type="button" class="shareWithEveryone" id="' + shareWithEveryoneButtonID + '" value="SHARE WITH EVERYONE" onclick="shareWithEveryone(' + parentID + ')" /><br>' +
|
'<input type="button"' + (hifiShareButtonsDisabled ? ' disabled="disabled"' : '') + ' class="shareWithEveryone" id="' + shareWithEveryoneButtonID + '" value="SHARE WITH EVERYONE" onclick="shareWithEveryone(' + parentID + ', ' + isGif + ')" /><br>' +
|
||||||
'<input type="checkbox" class="inviteConnections" id="' + inviteConnectionsCheckboxID + '" checked="checked" />' +
|
'<input type="checkbox"' + (hifiShareButtonsDisabled ? ' disabled="disabled"' : '') + ' class="inviteConnections" id="' + inviteConnectionsCheckboxID + '" checked="checked" />' +
|
||||||
'<label class="shareButtonLabel" for="' + inviteConnectionsCheckboxID + '">Invite My Connections</label><br>' +
|
'<label class="shareButtonLabel" for="' + inviteConnectionsCheckboxID + '">Invite My Connections</label><br>' +
|
||||||
'<input type="button" class="cancelShare" value="CANCEL" onclick="cancelSharing(' + parentID + ')" />' +
|
'<input type="button" class="cancelShare" value="CANCEL" onclick="cancelSharing(' + parentID + ')" />' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
|
@ -152,13 +152,18 @@ function shareForUrl(selectedID) {
|
||||||
data: paths[parseInt(selectedID.substring(1))]
|
data: paths[parseInt(selectedID.substring(1))]
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
function shareWithEveryone(selectedID) {
|
function shareWithEveryone(selectedID, isGif) {
|
||||||
selectedID = selectedID.id; // Why is this necessary?
|
selectedID = selectedID.id; // Why is this necessary?
|
||||||
|
|
||||||
|
document.getElementById(selectedID + "shareWithEveryoneButton").setAttribute("disabled", "disabled");
|
||||||
|
document.getElementById(selectedID + "inviteConnectionsCheckbox").setAttribute("disabled", "disabled");
|
||||||
|
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "snapshot",
|
type: "snapshot",
|
||||||
action: "shareSnapshotWithEveryone",
|
action: "shareSnapshotWithEveryone",
|
||||||
story_id: document.getElementById(selectedID).getAttribute("data-story-id")
|
story_id: document.getElementById(selectedID).getAttribute("data-story-id"),
|
||||||
|
isAnnouncement: document.getElementById(selectedID + "inviteConnectionsCheckbox").getAttribute("checked"),
|
||||||
|
isGif: isGif
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
function shareButtonClicked(selectedID) {
|
function shareButtonClicked(selectedID) {
|
||||||
|
@ -233,7 +238,7 @@ window.onload = function () {
|
||||||
var messageOptions = message.options;
|
var messageOptions = message.options;
|
||||||
imageCount = message.image_data.length;
|
imageCount = message.image_data.length;
|
||||||
message.image_data.forEach(function (element, idx, array) {
|
message.image_data.forEach(function (element, idx, array) {
|
||||||
addImage(element, true, true, message.canShare);
|
addImage(element, true, true, message.canShare, message.image_data[idx].buttonDisabled);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case 'addImages':
|
case 'addImages':
|
||||||
|
|
|
@ -143,21 +143,38 @@ function onMessage(message) {
|
||||||
case 'shareSnapshotWithEveryone':
|
case 'shareSnapshotWithEveryone':
|
||||||
isLoggedIn = Account.isLoggedIn();
|
isLoggedIn = Account.isLoggedIn();
|
||||||
storyIDsToMaybeDelete.splice(storyIDsToMaybeDelete.indexOf(message.story_id), 1);
|
storyIDsToMaybeDelete.splice(storyIDsToMaybeDelete.indexOf(message.story_id), 1);
|
||||||
|
if (message.isGif) {
|
||||||
|
Settings.setValue("previousAnimatedSnapSharingDisabled", true);
|
||||||
|
} else {
|
||||||
|
Settings.setValue("previousStillSnapSharingDisabled", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
var requestBody = {
|
||||||
|
audience: "for_feed"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.isAnnouncement) {
|
||||||
|
requestBody.action = "announcement";
|
||||||
|
}
|
||||||
|
|
||||||
if (isLoggedIn) {
|
if (isLoggedIn) {
|
||||||
print('Modifying audience of story ID', message.story_id, "to 'for_feed'");
|
print('Modifying audience of story ID', message.story_id, "to 'for_feed'");
|
||||||
request({
|
request({
|
||||||
uri: METAVERSE_BASE + '/api/v1/user_stories/' + message.story_id,
|
uri: METAVERSE_BASE + '/api/v1/user_stories/' + message.story_id,
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
json: true,
|
json: true,
|
||||||
body: {
|
body: requestBody
|
||||||
audience: "for_feed",
|
|
||||||
}
|
|
||||||
}, function (error, response) {
|
}, function (error, response) {
|
||||||
if (error || (response.status !== 'success')) {
|
if (error || (response.status !== 'success')) {
|
||||||
print("ERROR changing audience: ", error || response.status);
|
print("ERROR changing audience: ", error || response.status);
|
||||||
|
if (message.isGif) {
|
||||||
|
Settings.setValue("previousAnimatedSnapSharingDisabled", false);
|
||||||
|
} else {
|
||||||
|
Settings.setValue("previousStillSnapSharingDisabled", false);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
print("SUCCESS changing audience!");
|
print("SUCCESS changing audience" + (message.isAnnouncement ? " and posting announcement!" : "!"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -195,8 +212,10 @@ var isInSnapshotReview = false;
|
||||||
function openSnapApp() {
|
function openSnapApp() {
|
||||||
var previousStillSnapPath = Settings.getValue("previousStillSnapPath");
|
var previousStillSnapPath = Settings.getValue("previousStillSnapPath");
|
||||||
var previousStillSnapStoryID = Settings.getValue("previousStillSnapStoryID");
|
var previousStillSnapStoryID = Settings.getValue("previousStillSnapStoryID");
|
||||||
|
var previousStillSnapSharingDisabled = Settings.getValue("previousStillSnapSharingDisabled");
|
||||||
var previousAnimatedSnapPath = Settings.getValue("previousAnimatedSnapPath");
|
var previousAnimatedSnapPath = Settings.getValue("previousAnimatedSnapPath");
|
||||||
var previousAnimatedSnapStoryID = Settings.getValue("previousAnimatedSnapStoryID");
|
var previousAnimatedSnapStoryID = Settings.getValue("previousAnimatedSnapStoryID");
|
||||||
|
var previousAnimatedSnapSharingDisabled = Settings.getValue("previousAnimatedSnapSharingDisabled");
|
||||||
snapshotOptions = {
|
snapshotOptions = {
|
||||||
containsGif: previousAnimatedSnapPath !== "",
|
containsGif: previousAnimatedSnapPath !== "",
|
||||||
processingGif: false,
|
processingGif: false,
|
||||||
|
@ -204,10 +223,10 @@ function openSnapApp() {
|
||||||
}
|
}
|
||||||
imageData = [];
|
imageData = [];
|
||||||
if (previousAnimatedSnapPath !== "") {
|
if (previousAnimatedSnapPath !== "") {
|
||||||
imageData.push({ localPath: previousAnimatedSnapPath, story_id: previousAnimatedSnapStoryID });
|
imageData.push({ localPath: previousAnimatedSnapPath, story_id: previousAnimatedSnapStoryID, buttonDisabled: previousAnimatedSnapSharingDisabled });
|
||||||
}
|
}
|
||||||
if (previousStillSnapPath !== "") {
|
if (previousStillSnapPath !== "") {
|
||||||
imageData.push({ localPath: previousStillSnapPath, story_id: previousStillSnapStoryID });
|
imageData.push({ localPath: previousStillSnapPath, story_id: previousStillSnapStoryID, buttonDisabled: previousStillSnapSharingDisabled });
|
||||||
}
|
}
|
||||||
tablet.gotoWebScreen(SNAPSHOT_REVIEW_URL);
|
tablet.gotoWebScreen(SNAPSHOT_REVIEW_URL);
|
||||||
tablet.webEventReceived.connect(onMessage);
|
tablet.webEventReceived.connect(onMessage);
|
||||||
|
|
Loading…
Reference in a new issue