diff --git a/backend/.bowerrc b/backend/.bowerrc
new file mode 100644
index 0000000..af3bf7a
--- /dev/null
+++ b/backend/.bowerrc
@@ -0,0 +1,3 @@
+{
+ "directory" : "public/app/bower_components"
+}
\ No newline at end of file
diff --git a/backend/bower.json b/backend/bower.json
new file mode 100644
index 0000000..c70b186
--- /dev/null
+++ b/backend/bower.json
@@ -0,0 +1,18 @@
+{
+ "name": "together-stream",
+ "description": "Watch videos together with others.",
+ "main": "index.html",
+ "dependencies": {
+ "polymer": "1.8.1",
+ "google-youtube": "^1.2.1",
+ "iron-input": "1.0.10",
+ "webcomponentsjs": "^0.7.24"
+ },
+ "resolutions": {
+ "webcomponentsjs": "v1",
+ "polymer": "^2.0.0-rc.1",
+ "iron-validatable-behavior": "2.0-preview",
+ "iron-meta": "2.0-preview",
+ "iron-a11y-announcer": "^1.0.0"
+ }
+}
diff --git a/backend/package.json b/backend/package.json
index 6000558..2363ccb 100644
--- a/backend/package.json
+++ b/backend/package.json
@@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"scripts": {
- "start": "node --max-old-space-size=400 app.js"
+ "start": "bower install && node --max-old-space-size=400 app.js"
},
"dependencies": {
"@newrelic/native-metrics": "^2.0.2",
diff --git a/backend/public/app/bower.json b/backend/public/app/bower.json
deleted file mode 100644
index d59e7e0..0000000
--- a/backend/public/app/bower.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "name": "together-stream",
- "description": "Watch videos together with others.",
- "main": "index.html",
- "dependencies": {
- "polymer": "Polymer/polymer#2.0-preview",
- "google-youtube": "^1.2.1",
- "iron-input": "2.0-preview"
- },
- "devDependencies": {
- "iron-component-page": "PolymerElements/iron-component-page#^1.0.0",
- "iron-demo-helpers": "PolymerElements/iron-demo-helpers#^1.0.0",
- "web-component-tester": "^4.0.0",
- "webcomponentsjs": "webcomponents/webcomponentsjs#^0.7.0"
- },
- "resolutions": {
- "webcomponentsjs": "v1",
- "polymer": "2.0-preview",
- "iron-validatable-behavior": "2.0-preview",
- "iron-meta": "2.0-preview"
- }
-}
diff --git a/backend/public/app/index.html b/backend/public/app/index.html
index 4a7ae20..348ca63 100644
--- a/backend/public/app/index.html
+++ b/backend/public/app/index.html
@@ -44,7 +44,7 @@
© Copyright IBM Corporation 2017. All Rights Reserved.
- - License
+ - License
- Privacy
- Feedback
- Developers
diff --git a/backend/public/app/src/behaviors/csync-behavior.html b/backend/public/app/src/behaviors/csync-behavior.html
index a5cb1bf..dbe0f43 100644
--- a/backend/public/app/src/behaviors/csync-behavior.html
+++ b/backend/public/app/src/behaviors/csync-behavior.html
@@ -189,11 +189,46 @@
sendChatMessage: function (message) {
let writeKey = this.csyncApp.key("streams." + this.streamId + ".chat." + this.generateUUID())
let timeOffset = this.timeOffset
- writeKey.write({
+ writeKey.write(JSON.stringify({
content: message.detail,
id: this.loggedInUserFacebookId,
- timestamp: (Date.now() - timeOffset) / 1000 // need to save in seconds from 2001
- }, {acl: csync.acl.PublicReadWrite})
+ timestamp: "" + (Date.now() - timeOffset) / 1000 // need to save in seconds from 2001
+ }), {acl: csync.acl.PublicReadWrite})
},
+ /**
+ * Validates with the server whether this stream id is valid.
+ * @param {string} streamId - Stream id input by the user on portal page.
+ * @param {function} callback - Function callback
+ */
+ isValidStreamId: function(streamId, callback) {
+ let listenerKey = this.csyncApp.key("streams.*")
+ let checkIfInvalid = function () {
+ if (!this.streamValidated) {
+ callback(false)
+ }
+ }
+ let listenerCallback = function (error, value) {
+ if (error) {
+ console.error(error)
+ return
+ }
+ // If value doesn't exist and is outdated, don't process it.
+ if (!value.exists) {
+ return
+ }
+
+ if (!this.streamValidated && value.key && value.key.indexOf(streamId) >= 0) {
+ this.set("streamValidated", true)
+ callback(true)
+ return
+ }
+
+ // Checking if invalid once all streams have been checked.
+ this.debounce("invalidStreamCallback", checkIfInvalid, 200)
+ // this.processMessageAndInsertIntoArray(value)
+ }.bind(this)
+
+ listenerKey.listen(listenerCallback)
+ }
};
\ No newline at end of file
diff --git a/backend/public/app/src/behaviors/server-behavior.html b/backend/public/app/src/behaviors/server-behavior.html
index 557b4db..e4b4c79 100644
--- a/backend/public/app/src/behaviors/server-behavior.html
+++ b/backend/public/app/src/behaviors/server-behavior.html
@@ -43,42 +43,6 @@
}
}.bind(this)
xhr.send(null);
- },
- /**
- * Validates with the server whether this stream id is valid.
- * @param {string} streamId - Stream id input by the user on portal page.
- */
- isValidStreamId: function(streamId, callback) {
- let xhr = new XMLHttpRequest();
-
- xhr.open('GET', '/invites', true);
- xhr.setRequestHeader('Authorization', this.serverAccessToken)
- xhr.onload = function () {
- if (xhr.status === 200) {
- let invitesArr = JSON.parse(xhr.response)
- var streamIdIsValid = false
-
- if (invitesArr) {
- invitesArr.forEach(function(invite) {
- let splitStr = invite.csync_path.split('.')
-
- if (splitStr[1] === streamId) {
- streamIdIsValid = true
- this.set("streamName", invite.stream_name)
- }
- }.bind(this))
- }
- callback(streamIdIsValid)
- } else if (xhr.status === 401) {
- // Get new server token when needing authentication expires.
- this.getServerAccessToken(function() {
- this.isValidStreamId(streamId, callback)
- }.bind(this))
- } else {
- console.error("Couldn't reach server.", xhr)
- }
- }.bind(this)
- xhr.send(null);
}
};
\ No newline at end of file
diff --git a/backend/public/app/src/shared-styles.html b/backend/public/app/src/shared-styles.html
index a4300aa..8440a91 100644
--- a/backend/public/app/src/shared-styles.html
+++ b/backend/public/app/src/shared-styles.html
@@ -269,10 +269,10 @@
border-right: solid 1px white;
}
- /*.more-links li:nth-of-type(3) {
+ .more-links li:nth-of-type(3) {
border-right: solid 1px white;
padding-right: 30px;
- }*/
+ }
@media (max-width: 963px) {
p {
diff --git a/backend/public/app/src/ts-app.html b/backend/public/app/src/ts-app.html
index 7b63c7a..0ac206d 100644
--- a/backend/public/app/src/ts-app.html
+++ b/backend/public/app/src/ts-app.html
@@ -102,16 +102,19 @@
* @param {string} streamId - New stream id.
*/
joinStream: function() {
+ let that = this
let showPortalPage = function () {
- this.isValidStreamId(this.streamId, function callback(isValid) {
- if (isValid) {
- this.set("showingPortalPage", false)
- this.authenticateWithFacebookAccessToken(this.facebookAccessToken, this.setupCsyncListeners.bind(this))
- } else {
- alert("Please input a valid stream id.")
- }
- }.bind(this))
- }.bind(this)
+ that.authenticateWithFacebookAccessToken(that.facebookAccessToken, function () {
+ that.isValidStreamId(that.streamId, function callback(isValid) {
+ if (isValid) {
+ that.setupCsyncListeners()
+ that.set("showingPortalPage", false)
+ } else {
+ alert("Please input a valid stream id.")
+ }
+ })
+ })
+ }
if (!this.isLoggedIn) {
this.fbLogin(function callback () {
diff --git a/backend/public/app/src/ts-chat-message.html b/backend/public/app/src/ts-chat-message.html
index a7eac53..a41b698 100644
--- a/backend/public/app/src/ts-chat-message.html
+++ b/backend/public/app/src/ts-chat-message.html
@@ -23,6 +23,9 @@
font-size: small;
margin: 2px;
}
+ .right-container p {
+ margin-top: -4px;
+ }
.inline {
display: flex;
}
diff --git a/backend/public/app/src/ts-chat.html b/backend/public/app/src/ts-chat.html
index 4fa5d83..85f3a1d 100644
--- a/backend/public/app/src/ts-chat.html
+++ b/backend/public/app/src/ts-chat.html
@@ -14,7 +14,8 @@
display: flex;
flex-direction: column;
justify-content: space-between;
- width: 30%
+ width: 30%;
+ height: 100%;
}
.bottom-container {
display: flex;
diff --git a/backend/public/app/src/ts-video.html b/backend/public/app/src/ts-video.html
index 1842160..30712f3 100644
--- a/backend/public/app/src/ts-video.html
+++ b/backend/public/app/src/ts-video.html
@@ -11,6 +11,10 @@