From 47dea0ea2b60ae1f06b940e5cbf30892e99da94f Mon Sep 17 00:00:00 2001 From: David Kelly Date: Wed, 10 Aug 2016 17:09:43 -0700 Subject: [PATCH] Hide sharing if not logged in, or in an accessible place The grand future will have option to login, and so on... --- scripts/system/html/ShareSnapshot.html | 25 ++++++++++++++++++++----- scripts/system/snapshot.js | 8 +++++++- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/scripts/system/html/ShareSnapshot.html b/scripts/system/html/ShareSnapshot.html index 4691b7488c..d838a01e99 100644 --- a/scripts/system/html/ShareSnapshot.html +++ b/scripts/system/html/ShareSnapshot.html @@ -28,16 +28,29 @@ paths.push(data); } + function handleShareButtons(canShare) { + if (!canShare) { + // hide the share/do not share buttons + document.getElementById("sharing").innerHTML = "

You can share if you are logged in and in a public place"; + } + } window.onload = function () { // Something like the following will allow testing in a browser. //addImage({localPath: 'c:/Users/howar/OneDrive/Pictures/hifi-snap-by--on-2016-07-27_12-58-43.jpg'}); openEventBridge(function () { // Set up a handler for receiving the data, and tell the .js we are ready to receive it. EventBridge.scriptEventReceived.connect(function (message) { + // last element of list contains a bool for whether or not we can share stuff + var canShare = message.pop().canShare; + print("canShare:"+canShare+", message:" + message.toString()) + handleShareButtons(canShare); + + // rest are image paths which we add message.forEach(addImage); }); EventBridge.emitWebEvent('ready'); }); + }; // beware of bug: Cannot send objects at top level. (Nested in arrays is fine.) shareSelected = function() { @@ -64,11 +77,13 @@

-
- -
-
- +
+
+ +
+
+ +
diff --git a/scripts/system/snapshot.js b/scripts/system/snapshot.js index 84019e68cc..0acb5d5acf 100644 --- a/scripts/system/snapshot.js +++ b/scripts/system/snapshot.js @@ -77,6 +77,10 @@ function onClicked() { }, SNAPSHOT_DELAY); } +function canShare() { + return Account.isLoggedIn() && Boolean(Window.location.placename); +} + function resetButtons(path, notify) { // show overlays if they were on if (resetOverlays) { @@ -90,7 +94,9 @@ function resetButtons(path, notify) { button.writeProperty("defaultState", 1); button.writeProperty("hoverState", 3); Window.snapshotTaken.disconnect(resetButtons); - confirmShare([{localPath: path}]); + + // last element in data array tells dialog whether we can share or not + confirmShare([ { localPath: path }, { canShare: canShare() } ]); } button.clicked.connect(onClicked);