mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 12:29:56 +02:00
Fix button state; use request()
This commit is contained in:
parent
6711e8cbc2
commit
b26f31704b
1 changed files with 36 additions and 32 deletions
|
@ -111,7 +111,7 @@ function onMessage(message) {
|
||||||
action: "showPreviousImages",
|
action: "showPreviousImages",
|
||||||
options: snapshotOptions,
|
options: snapshotOptions,
|
||||||
image_data: imageData,
|
image_data: imageData,
|
||||||
canShare: !!isDomainOpen(Settings.getValue("previousSnapshotDomainID"))
|
canShare: !isDomainOpen(Settings.getValue("previousSnapshotDomainID"))
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
tablet.emitScriptEvent(JSON.stringify({
|
tablet.emitScriptEvent(JSON.stringify({
|
||||||
|
@ -229,11 +229,13 @@ function onMessage(message) {
|
||||||
|
|
||||||
var SNAPSHOT_REVIEW_URL = Script.resolvePath("html/SnapshotReview.html");
|
var SNAPSHOT_REVIEW_URL = Script.resolvePath("html/SnapshotReview.html");
|
||||||
var isInSnapshotReview = false;
|
var isInSnapshotReview = false;
|
||||||
|
var shouldActivateButton = false;
|
||||||
function onButtonClicked() {
|
function onButtonClicked() {
|
||||||
if (isInSnapshotReview){
|
if (isInSnapshotReview){
|
||||||
// for toolbar-mode: go back to home screen, this will close the window.
|
// for toolbar-mode: go back to home screen, this will close the window.
|
||||||
tablet.gotoHomeScreen();
|
tablet.gotoHomeScreen();
|
||||||
} else {
|
} else {
|
||||||
|
shouldActivateButton = true;
|
||||||
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 previousStillSnapSharingDisabled = Settings.getValue("previousStillSnapSharingDisabled");
|
||||||
|
@ -343,7 +345,7 @@ function isDomainOpen(id) {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var request = new XMLHttpRequest();
|
|
||||||
var options = [
|
var options = [
|
||||||
'now=' + new Date().toISOString(),
|
'now=' + new Date().toISOString(),
|
||||||
'include_actions=concurrency',
|
'include_actions=concurrency',
|
||||||
|
@ -351,15 +353,19 @@ function isDomainOpen(id) {
|
||||||
'restriction=open,hifi' // If we're sharing, we're logged in
|
'restriction=open,hifi' // If we're sharing, we're logged in
|
||||||
// If we're here, protocol matches, and it is online
|
// If we're here, protocol matches, and it is online
|
||||||
];
|
];
|
||||||
var url = location.metaverseServerUrl + "/api/v1/user_stories?" + options.join('&');
|
var url = METAVERSE_BASE + "/api/v1/user_stories?" + options.join('&');
|
||||||
request.open("GET", url, false);
|
|
||||||
request.send();
|
return request({
|
||||||
if (request.status !== 200) {
|
uri: url,
|
||||||
return false;
|
method: 'GET'
|
||||||
}
|
}, function (error, response) {
|
||||||
var response = JSON.parse(request.response); // Not parsed for us.
|
if (error || (response.status !== 'success')) {
|
||||||
return (response.status === 'success') &&
|
print("ERROR getting open status of domain: ", error || response.status);
|
||||||
response.total_entries;
|
return false;
|
||||||
|
} else {
|
||||||
|
return response.total_entries;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function stillSnapshotTaken(pathStillSnapshot, notify) {
|
function stillSnapshotTaken(pathStillSnapshot, notify) {
|
||||||
|
@ -382,7 +388,7 @@ function stillSnapshotTaken(pathStillSnapshot, notify) {
|
||||||
snapshotOptions = {
|
snapshotOptions = {
|
||||||
containsGif: false,
|
containsGif: false,
|
||||||
processingGif: false,
|
processingGif: false,
|
||||||
canShare: !!isDomainOpen(domainId)
|
canShare: !isDomainOpen(domainId)
|
||||||
};
|
};
|
||||||
imageData = [{ localPath: pathStillSnapshot, href: href }];
|
imageData = [{ localPath: pathStillSnapshot, href: href }];
|
||||||
Settings.setValue("previousStillSnapPath", pathStillSnapshot);
|
Settings.setValue("previousStillSnapPath", pathStillSnapshot);
|
||||||
|
@ -414,7 +420,7 @@ function processingGifStarted(pathStillSnapshot) {
|
||||||
containsGif: true,
|
containsGif: true,
|
||||||
processingGif: true,
|
processingGif: true,
|
||||||
loadingGifPath: Script.resolvePath(Script.resourcesPath() + 'icons/loadingDark.gif'),
|
loadingGifPath: Script.resolvePath(Script.resourcesPath() + 'icons/loadingDark.gif'),
|
||||||
canShare: !!isDomainOpen(domainId)
|
canShare: !isDomainOpen(domainId)
|
||||||
};
|
};
|
||||||
imageData = [{ localPath: pathStillSnapshot, href: href }];
|
imageData = [{ localPath: pathStillSnapshot, href: href }];
|
||||||
Settings.setValue("previousStillSnapPath", pathStillSnapshot);
|
Settings.setValue("previousStillSnapPath", pathStillSnapshot);
|
||||||
|
@ -442,7 +448,7 @@ function processingGifCompleted(pathAnimatedSnapshot) {
|
||||||
snapshotOptions = {
|
snapshotOptions = {
|
||||||
containsGif: true,
|
containsGif: true,
|
||||||
processingGif: false,
|
processingGif: false,
|
||||||
canShare: !!isDomainOpen(domainId)
|
canShare: !isDomainOpen(domainId)
|
||||||
}
|
}
|
||||||
imageData = [{ localPath: pathAnimatedSnapshot, href: href }];
|
imageData = [{ localPath: pathAnimatedSnapshot, href: href }];
|
||||||
Settings.setValue("previousAnimatedSnapPath", pathAnimatedSnapshot);
|
Settings.setValue("previousAnimatedSnapPath", pathAnimatedSnapshot);
|
||||||
|
@ -455,26 +461,24 @@ function processingGifCompleted(pathAnimatedSnapshot) {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
function maybeDeleteSnapshotStories() {
|
function maybeDeleteSnapshotStories() {
|
||||||
if (storyIDsToMaybeDelete.length > 0) {
|
storyIDsToMaybeDelete.forEach(function (element, idx, array) {
|
||||||
print("User took new snapshot & didn't share old one(s); deleting old snapshot stories");
|
request({
|
||||||
storyIDsToMaybeDelete.forEach(function (element, idx, array) {
|
uri: METAVERSE_BASE + '/api/v1/user_stories/' + element,
|
||||||
request({
|
method: 'DELETE'
|
||||||
uri: METAVERSE_BASE + '/api/v1/user_stories/' + element,
|
}, function (error, response) {
|
||||||
method: 'DELETE'
|
if (error || (response.status !== 'success')) {
|
||||||
}, function (error, response) {
|
print("ERROR deleting snapshot story: ", error || response.status);
|
||||||
if (error || (response.status !== 'success')) {
|
return;
|
||||||
print("ERROR deleting snapshot story: ", error || response.status);
|
} else {
|
||||||
return;
|
print("SUCCESS deleting snapshot story with ID", element);
|
||||||
} else {
|
}
|
||||||
print("SUCCESS deleting snapshot story with ID", element);
|
})
|
||||||
}
|
});
|
||||||
})
|
storyIDsToMaybeDelete = [];
|
||||||
});
|
|
||||||
storyIDsToMaybeDelete = [];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
function onTabletScreenChanged(type, url) {
|
function onTabletScreenChanged(type, url) {
|
||||||
button.editProperties({ isActive: !isInSnapshotReview });
|
button.editProperties({ isActive: shouldActivateButton });
|
||||||
|
shouldActivateButton = false;
|
||||||
if (isInSnapshotReview) {
|
if (isInSnapshotReview) {
|
||||||
tablet.webEventReceived.disconnect(onMessage);
|
tablet.webEventReceived.disconnect(onMessage);
|
||||||
isInSnapshotReview = false;
|
isInSnapshotReview = false;
|
||||||
|
|
Loading…
Reference in a new issue