PR feedback

This commit is contained in:
David Kelly 2016-08-11 11:47:55 -07:00
parent 47dea0ea2b
commit c1edd008a4
2 changed files with 19 additions and 15 deletions

View file

@ -28,10 +28,16 @@
paths.push(data); paths.push(data);
} }
function handleShareButtons(canShare) { function handleShareButtons(shareMsg) {
if (!canShare) { if (!shareMsg.canShare) {
// hide the share/do not share buttons // this means you may or may not be logged in, but can't share
document.getElementById("sharing").innerHTML = "<p>You can share if you are logged in and in a public place"; // because you are not in a public place.
document.getElementById("sharing").innerHTML = "<p>You can share if you are in a public place";
} else if (!shareMsg.isLoggedIn) {
// this means you are in a public place, but can't share because
// you need to login. Soon we will just bring up the share dialog
// in this case (and maybe set a boolean here to inform the html)
document.getElementById("sharing").innerHTML = "<p>You can share if you are logged in";
} }
} }
window.onload = function () { window.onload = function () {
@ -41,9 +47,8 @@
// Set up a handler for receiving the data, and tell the .js we are ready to receive it. // Set up a handler for receiving the data, and tell the .js we are ready to receive it.
EventBridge.scriptEventReceived.connect(function (message) { EventBridge.scriptEventReceived.connect(function (message) {
// last element of list contains a bool for whether or not we can share stuff // last element of list contains a bool for whether or not we can share stuff
var canShare = message.pop().canShare; var shareMsg = message.pop();
print("canShare:"+canShare+", message:" + message.toString()) handleShareButtons(shareMsg);
handleShareButtons(canShare);
// rest are image paths which we add // rest are image paths which we add
message.forEach(addImage); message.forEach(addImage);
@ -74,10 +79,10 @@
<div class="section-header"> <div class="section-header">
<label>Snapshots sucessfully saved!</label> <label>Snapshots sucessfully saved!</label>
</div> </div>
<div class="sub-section-header">
<label>Would you like to share?</label>
</div>
<div id="sharing"> <div id="sharing">
<div class="sub-section-header">
<label>Would you like to share?</label>
</div>
<div class="sub-section-header"> <div class="sub-section-header">
<input type="button" id="share" value="SHARE IN FEED" onclick="shareSelected()"/> <input type="button" id="share" value="SHARE IN FEED" onclick="shareSelected()"/>
</div> </div>

View file

@ -77,10 +77,6 @@ function onClicked() {
}, SNAPSHOT_DELAY); }, SNAPSHOT_DELAY);
} }
function canShare() {
return Account.isLoggedIn() && Boolean(Window.location.placename);
}
function resetButtons(path, notify) { function resetButtons(path, notify) {
// show overlays if they were on // show overlays if they were on
if (resetOverlays) { if (resetOverlays) {
@ -96,7 +92,10 @@ function resetButtons(path, notify) {
Window.snapshotTaken.disconnect(resetButtons); Window.snapshotTaken.disconnect(resetButtons);
// last element in data array tells dialog whether we can share or not // last element in data array tells dialog whether we can share or not
confirmShare([ { localPath: path }, { canShare: canShare() } ]); confirmShare([
{ localPath: path },
{ canShare: Boolean(Window.location.placename), isLoggedIn: Account.isLoggedIn() }
]);
} }
button.clicked.connect(onClicked); button.clicked.connect(onClicked);