From ef2e5f78fff6c01a6badc1319729652acc7b6f3c Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 24 Apr 2017 17:41:37 -0700 Subject: [PATCH] Startings of needsLogin support --- scripts/system/snapshot.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/scripts/system/snapshot.js b/scripts/system/snapshot.js index 95a76a9188..0ac809f8a7 100644 --- a/scripts/system/snapshot.js +++ b/scripts/system/snapshot.js @@ -149,16 +149,16 @@ function onMessage(message) { Settings.setValue("previousStillSnapSharingDisabled", true); } - var requestBody = { - audience: "for_feed" - } - - if (message.isAnnouncement) { - requestBody.action = "announcement"; - } - if (isLoggedIn) { print('Modifying audience of story ID', message.story_id, "to 'for_feed'"); + var requestBody = { + audience: "for_feed" + } + + if (message.isAnnouncement) { + requestBody.action = "announcement"; + print('...Also announcing!'); + } request({ uri: METAVERSE_BASE + '/api/v1/user_stories/' + message.story_id, method: 'PUT', @@ -178,14 +178,10 @@ function onMessage(message) { } }); } else { - // TODO - /* needsLogin = true; shareAfterLogin = true; snapshotToShareAfterLogin = { path: message.data, href: message.href || href }; - */ } - /* if (needsLogin) { if ((HMD.active && Settings.getValue("hmdTabletBecomesToolbar")) || (!HMD.active && Settings.getValue("desktopTabletBecomesToolbar"))) { @@ -194,7 +190,7 @@ function onMessage(message) { tablet.loadQMLOnTop("../../dialogs/TabletLoginDialog.qml"); HMD.openTablet(); } - }*/ + } break; case 'shareButtonClicked': print('Twitter or FB "Share" button clicked! Removing ID', message.story_id, 'from storyIDsToMaybeDelete[].'); @@ -265,8 +261,10 @@ function takeSnapshot() { })); Settings.setValue("previousStillSnapPath", ""); Settings.setValue("previousStillSnapStoryID", ""); + Settings.setValue("previousStillSnapSharingDisabled", false); Settings.setValue("previousAnimatedSnapPath", ""); Settings.setValue("previousAnimatedSnapStoryID", ""); + Settings.setValue("previousAnimatedSnapSharingDisabled", false); // Raising the desktop for the share dialog at end will interact badly with clearOverlayWhenMoving. // Turn it off now, before we start futzing with things (and possibly moving). @@ -452,7 +450,7 @@ function onTabletScreenChanged(type, url) { isInSnapshotReview = false; } } -function onConnected() { +function onUsernameChanged() { if (shareAfterLogin && Account.isLoggedIn()) { print('Sharing snapshot after login:', snapshotToShareAfterLogin.path); Window.shareSnapshot(snapshotToShareAfterLogin.path, snapshotToShareAfterLogin.href); @@ -464,7 +462,7 @@ button.clicked.connect(openSnapApp); buttonConnected = true; Window.snapshotShared.connect(snapshotUploaded); tablet.screenChanged.connect(onTabletScreenChanged); -Account.usernameChanged.connect(onConnected); +Account.usernameChanged.connect(onUsernameChanged); Script.scriptEnding.connect(function () { if (buttonConnected) { button.clicked.disconnect(openSnapApp);