mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 08:04:01 +02:00
persist "open feed after" checkbox setting
This commit is contained in:
parent
0f415abd6b
commit
5e8722ccf5
2 changed files with 24 additions and 10 deletions
|
@ -84,6 +84,9 @@
|
|||
|
||||
}
|
||||
function handleShareButtons(shareMsg) {
|
||||
var openFeed = document.getElementById('openFeed');
|
||||
openFeed.checked = shareMsg.openFeedAfterShare;
|
||||
openFeed.onchange = function () { EventBridge.emitWebEvent(openFeed.checked ? 'setOpenFeedTrue' : 'setOpenFeedFalse'); };
|
||||
if (!shareMsg.canShare) {
|
||||
// this means you may or may not be logged in, but can't share
|
||||
// because you are not in a public place.
|
||||
|
@ -116,10 +119,10 @@
|
|||
};
|
||||
// beware of bug: Cannot send objects at top level. (Nested in arrays is fine.)
|
||||
shareSelected = function () {
|
||||
EventBridge.emitWebEvent(paths.concat({openFeed: document.getElementById("openFeed").checked}));
|
||||
EventBridge.emitWebEvent(paths);
|
||||
};
|
||||
doNotShare = function () {
|
||||
EventBridge.emitWebEvent([{openFeed: document.getElementById("openFeed").checked}]);
|
||||
EventBridge.emitWebEvent([]);
|
||||
};
|
||||
snapshotSettings = function () {
|
||||
EventBridge.emitWebEvent("openSettings");
|
||||
|
|
|
@ -20,23 +20,32 @@ var button = toolBar.addButton({
|
|||
alpha: 0.9,
|
||||
});
|
||||
|
||||
function shouldOpenFeedAfterShare() {
|
||||
var persisted = Settings.getValue('openFeedAfterShare', true); // might answer true, false, "true", or "false"
|
||||
return persisted && (persisted !== 'false');
|
||||
}
|
||||
function showFeedWindow() {
|
||||
DialogsManager.showFeed();
|
||||
}
|
||||
|
||||
var openFeed, outstanding;
|
||||
var outstanding;
|
||||
function confirmShare(data) {
|
||||
var dialog = new OverlayWebWindow('Snapshot Review', Script.resolvePath("html/ShareSnapshot.html"), 800, 470);
|
||||
function onMessage(message) {
|
||||
switch (message) {
|
||||
case 'ready':
|
||||
dialog.emitScriptEvent(data); // Send it.
|
||||
openFeed = false;
|
||||
outstanding = 0;
|
||||
break;
|
||||
case 'openSettings':
|
||||
Desktop.show("hifi/dialogs/GeneralPreferencesDialog.qml", "GeneralPreferencesDialog");
|
||||
break;
|
||||
case 'setOpenFeedFalse':
|
||||
Settings.setValue('openFeedAfterShare', false)
|
||||
break;
|
||||
case 'setOpenFeedTrue':
|
||||
Settings.setValue('openFeedAfterShare', true)
|
||||
break;
|
||||
default:
|
||||
dialog.webEventReceived.disconnect(onMessage); // I'm not certain that this is necessary. If it is, what do we do on normal close?
|
||||
dialog.close();
|
||||
|
@ -46,11 +55,9 @@ function confirmShare(data) {
|
|||
print('sharing', submessage.localPath);
|
||||
outstanding++;
|
||||
Window.shareSnapshot(submessage.localPath);
|
||||
} else if (submessage.openFeed) {
|
||||
openFeed = true;
|
||||
}
|
||||
});
|
||||
if (openFeed && !outstanding) {
|
||||
if (!outstanding && shouldOpenFeedAfterShare()) {
|
||||
showFeedWindow();
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +74,7 @@ function snapshotShared(success) {
|
|||
// for now just print an error.
|
||||
print('snapshot upload/share failed');
|
||||
}
|
||||
if ((--outstanding <= 0) && openFeed) {
|
||||
if ((--outstanding <= 0) && shouldOpenFeedAfterShare()) {
|
||||
showFeedWindow();
|
||||
}
|
||||
}
|
||||
|
@ -114,8 +121,12 @@ function resetButtons(path, notify) {
|
|||
|
||||
// last element in data array tells dialog whether we can share or not
|
||||
confirmShare([
|
||||
{ localPath: path },
|
||||
{ canShare: Boolean(Window.location.placename), isLoggedIn: Account.isLoggedIn() }
|
||||
{ localPath: path },
|
||||
{
|
||||
canShare: Boolean(Window.location.placename),
|
||||
isLoggedIn: Account.isLoggedIn(),
|
||||
openFeedAfterShare: shouldOpenFeedAfterShare()
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue