diff --git a/functions/firebase-debug.log b/functions/firebase-debug.log deleted file mode 100644 index bc00235..0000000 --- a/functions/firebase-debug.log +++ /dev/null @@ -1,143 +0,0 @@ -[debug] [2020-04-24T18:07:31.093Z] ---------------------------------------------------------------------- -[debug] [2020-04-24T18:07:31.096Z] Command: /usr/local/bin/node /usr/local/bin/firebase deploy --only functions -[debug] [2020-04-24T18:07:31.096Z] CLI Version: 7.14.0 -[debug] [2020-04-24T18:07:31.096Z] Platform: darwin -[debug] [2020-04-24T18:07:31.096Z] Node Version: v12.16.1 -[debug] [2020-04-24T18:07:31.097Z] Time: Fri Apr 24 2020 14:07:31 GMT-0400 (Eastern Daylight Time) -[debug] [2020-04-24T18:07:31.097Z] ---------------------------------------------------------------------- -[debug] [2020-04-24T18:07:31.097Z] -[debug] [2020-04-24T18:07:31.114Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"] -[debug] [2020-04-24T18:07:31.115Z] > authorizing via signed-in user -[debug] [2020-04-24T18:07:31.115Z] [iam] checking project watch-party-crx for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"] -[debug] [2020-04-24T18:07:31.117Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"] -[debug] [2020-04-24T18:07:31.117Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token - -[debug] [2020-04-24T18:07:31.283Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:31.289Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/watch-party-crx:testIamPermissions - -[debug] [2020-04-24T18:07:31.524Z] <<< HTTP RESPONSE 200 -[info] -[info] === Deploying to 'watch-party-crx'... -[info] -[info] i deploying functions -[info] Running command: npm --prefix "$RESOURCE_DIR" run lint -[info] ✔ functions: Finished running predeploy script. -[debug] [2020-04-24T18:07:36.485Z] > [functions] package.json contents: { - "name": "watchparty", - "version": "1.0.0-beta", - "description": "Cloud Functions for Watch Party", - "scripts": { - "lint": "eslint .", - "serve": "firebase emulators:start --only functions", - "shell": "firebase functions:shell", - "start": "npm run shell", - "deploy": "firebase deploy --only functions", - "logs": "firebase functions:log" - }, - "engines": { - "node": "8" - }, - "dependencies": { - "cors": "^2.8.5", - "express": "^4.17.1", - "firebase-admin": "^8.6.0", - "firebase-functions": "^3.3.0" - }, - "devDependencies": { - "eslint": "^5.12.0", - "eslint-plugin-promise": "^4.0.1", - "firebase-functions-test": "^0.1.6" - }, - "private": true -} -[info] i functions: ensuring necessary APIs are enabled... -[debug] [2020-04-24T18:07:36.486Z] >>> HTTP REQUEST GET https://serviceusage.googleapis.com/v1/projects/watch-party-crx/services/cloudfunctions.googleapis.com - -[debug] [2020-04-24T18:07:36.486Z] >>> HTTP REQUEST GET https://serviceusage.googleapis.com/v1/projects/watch-party-crx/services/runtimeconfig.googleapis.com - -[debug] [2020-04-24T18:07:36.867Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:36.871Z] <<< HTTP RESPONSE 200 -[info] ✔ functions: all necessary APIs are enabled -[debug] [2020-04-24T18:07:36.872Z] >>> HTTP REQUEST GET https://firebase.googleapis.com/v1beta1/projects/watch-party-crx/adminSdkConfig - -[debug] [2020-04-24T18:07:37.113Z] <<< HTTP RESPONSE 200 -[info] i functions: preparing functions directory for uploading... -[debug] [2020-04-24T18:07:37.116Z] >>> HTTP REQUEST GET https://runtimeconfig.googleapis.com/v1beta1/projects/watch-party-crx/configs - -[debug] [2020-04-24T18:07:37.320Z] <<< HTTP RESPONSE 200 -[info] i functions: packaged functions (44.76 KB) for uploading -[debug] [2020-04-24T18:07:37.658Z] >>> HTTP REQUEST POST https://cloudfunctions.googleapis.com/v1/projects/watch-party-crx/locations/us-central1/functions:generateUploadUrl - -[debug] [2020-04-24T18:07:38.546Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:38.546Z] >>> HTTP REQUEST PUT https://storage.googleapis.com/gcf-upload-us-central1-a4ea9772-3dd8-4303-8415-cd76dd6c16e9/921c6289-5681-487f-b045-33da931235ac.zip?GoogleAccessId=service-712242707190@gcf-admin-robot.iam.gserviceaccount.com&Expires=1587753458&Signature=PGSCfGryU1TcJWqUQVehHtdzJ2l0s%2BXpwssevFPFQ1TbasQ3ogsBLrDxY%2B7%2FRRzDXhSQCyhDNhqbykvwyonKUvjZsCbEHxv7cS%2FLHtlsSnz%2F3R6aBZVgaT6L8fYlMiSHehf5WUiOlRT7rcORQsiCBIZN582fP5HlTJq8A5Utrrg1cYyAZSYmDuUBdk9ijh1mYVx8MacUtGDVIUVj4xguN%2FJvh47tzaT1tS34YSi3%2BzrnuMKyenHEYToiDPuaDWjl%2BlcWpfU8EQWwB3qiZ01UP2DkprngrfmHPzuPT%2BmdWqb6L6cJKMvgfM%2B%2Fu8BdRHQFQQRNg9AZl6%2FZWSUZCk1D7Q%3D%3D - -[debug] [2020-04-24T18:07:38.778Z] <<< HTTP RESPONSE 200 -[info] ✔ functions: functions folder uploaded successfully -[debug] [2020-04-24T18:07:38.780Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/projects/watch-party-crx/locations/-/functions - -[debug] [2020-04-24T18:07:39.306Z] <<< HTTP RESPONSE 200 -[info] i functions: updating Node.js 8 function widgets(us-central1)... -[debug] [2020-04-24T18:07:39.308Z] Trigger is: {"httpsTrigger":{}} -[info] i functions: updating Node.js 8 function scheduledCleanUp(us-central1)... -[debug] [2020-04-24T18:07:39.308Z] Trigger is: {"eventTrigger":{"resource":"projects/watch-party-crx/topics/firebase-schedule-scheduledCleanUp-us-central1","eventType":"google.pubsub.topic.publish","service":"pubsub.googleapis.com"}} -[info] i scheduler: ensuring necessary APIs are enabled... -[info] i pubsub: ensuring necessary APIs are enabled... -[debug] [2020-04-24T18:07:39.310Z] >>> HTTP REQUEST GET https://serviceusage.googleapis.com/v1/projects/watch-party-crx/services/cloudscheduler.googleapis.com - -[debug] [2020-04-24T18:07:39.310Z] >>> HTTP REQUEST GET https://serviceusage.googleapis.com/v1/projects/watch-party-crx/services/pubsub.googleapis.com - -[debug] [2020-04-24T18:07:39.796Z] <<< HTTP RESPONSE 200 -[info] ✔ pubsub: all necessary APIs are enabled -[debug] [2020-04-24T18:07:40.006Z] <<< HTTP RESPONSE 200 -[info] ✔ scheduler: all necessary APIs are enabled -[debug] [2020-04-24T18:07:40.008Z] >>> HTTP REQUEST GET https://cloudscheduler.googleapis.com/v1beta1/projects/watch-party-crx/locations/us-central1/jobs/firebase-schedule-scheduledCleanUp-us-central1 - -[debug] [2020-04-24T18:07:40.399Z] <<< HTTP RESPONSE 200 -[info] i functions: scheduler job firebase-schedule-scheduledCleanUp-us-central1 is up to date, no changes required -[debug] [2020-04-24T18:07:40.401Z] >>> HTTP REQUEST PATCH https://cloudfunctions.googleapis.com/v1/projects/watch-party-crx/locations/us-central1/functions/widgets {"updateMask":"sourceUploadUrl,name,labels,runtime,httpsTrigger"} - -[debug] [2020-04-24T18:07:40.402Z] >>> HTTP REQUEST PATCH https://cloudfunctions.googleapis.com/v1/projects/watch-party-crx/locations/us-central1/functions/scheduledCleanUp {"updateMask":"sourceUploadUrl,name,labels,runtime,eventTrigger.resource,eventTrigger.eventType,eventTrigger.service"} - -[debug] [2020-04-24T18:07:41.048Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:41.069Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:41.070Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/projects/watch-party-crx/locations/-/functions - -[debug] [2020-04-24T18:07:41.567Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:41.568Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3dpZGdldHMvdDltZHdiLUZSWm8 - -[debug] [2020-04-24T18:07:41.569Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3NjaGVkdWxlZENsZWFuVXAvNUdFSXJmSFZKYjQ - -[debug] [2020-04-24T18:07:41.934Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:41.944Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:43.935Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3NjaGVkdWxlZENsZWFuVXAvNUdFSXJmSFZKYjQ - -[debug] [2020-04-24T18:07:43.946Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3dpZGdldHMvdDltZHdiLUZSWm8 - -[debug] [2020-04-24T18:07:44.320Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:44.321Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:46.322Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3dpZGdldHMvdDltZHdiLUZSWm8 - -[debug] [2020-04-24T18:07:46.322Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3NjaGVkdWxlZENsZWFuVXAvNUdFSXJmSFZKYjQ - -[debug] [2020-04-24T18:07:46.659Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:46.689Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:48.661Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3dpZGdldHMvdDltZHdiLUZSWm8 - -[debug] [2020-04-24T18:07:48.692Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3NjaGVkdWxlZENsZWFuVXAvNUdFSXJmSFZKYjQ - -[debug] [2020-04-24T18:07:49.046Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:49.114Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:51.048Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3dpZGdldHMvdDltZHdiLUZSWm8 - -[debug] [2020-04-24T18:07:51.113Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3NjaGVkdWxlZENsZWFuVXAvNUdFSXJmSFZKYjQ - -[debug] [2020-04-24T18:07:51.508Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:51.515Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:53.509Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3dpZGdldHMvdDltZHdiLUZSWm8 - -[debug] [2020-04-24T18:07:53.517Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3NjaGVkdWxlZENsZWFuVXAvNUdFSXJmSFZKYjQ - -[debug] [2020-04-24T18:07:53.692Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:53.860Z] <<< HTTP RESPONSE 200 -[debug] [2020-04-24T18:07:55.695Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/d2F0Y2gtcGFydHktY3J4L3VzLWNlbnRyYWwxL3dpZGdldHMvdDltZHdiLUZSWm8 - diff --git a/functions/index.js b/functions/index.js index 1f5ad67..4bdb634 100644 --- a/functions/index.js +++ b/functions/index.js @@ -88,8 +88,8 @@ const createRoom = async (req, res) => { .add({ name: bodydata.roomName, player: bodydata.player, - createdAt: new Date().toISOString(), - updatedAt: new Date().toISOString(), + createdAt: new Date(), + updatedAt: new Date(), }) .then((ref) => ref.id) .catch((err) => { @@ -105,7 +105,7 @@ const createRoom = async (req, res) => { uid: '', name: '', text: `${bodydata.userName} started the party.`, - time: new Date().toISOString(), + time: new Date(), }) .catch((err) => { console.error(`Failed to add system create party message : \n\t Room: ${roomId}`, err); @@ -176,7 +176,7 @@ const joinRoom = async (req, res) => { uid: '', name: '', text: `${bodydata.userName} joined the party.`, - time: new Date().toISOString(), + time: new Date(), }) .catch((err) => { console.error( @@ -205,7 +205,7 @@ const joinRoom = async (req, res) => { .collection('rooms') .doc(bodydata.roomId) .update({ - updatedAt: new Date().toISOString(), + updatedAt: new Date(), }) .catch((err) => { console.error( @@ -239,7 +239,7 @@ const sendMessage = async (req, res) => { .add({ name, text: text || '', - time, + time: new Date(), uid, type: type || '', }) @@ -252,7 +252,7 @@ const sendMessage = async (req, res) => { .collection('rooms') .doc(roomId) .update({ - updatedAt: new Date().toISOString(), + updatedAt: new Date(), }) .catch((err) => { console.error( @@ -409,7 +409,7 @@ const updatePlayer = async (req, res) => { uid: '', name: '', text: `${userName} ${statusString} ${timeString}`, - time: new Date().toISOString(), + time: new Date(), }) .catch((err) => { console.error( @@ -445,7 +445,7 @@ app.post('/updatePlayer', updatePlayer); exports.widgets = functions.https.onRequest(app); exports.scheduledCleanUp = functions.pubsub.schedule('every 60 minutes').onRun(async () => { - const startedTime = new Date().toISOString(); + const startedTime = new Date(); const roomList = await admin .firestore() .collection('rooms') diff --git a/public/background.js b/public/background.js index 93412a4..531785d 100644 --- a/public/background.js +++ b/public/background.js @@ -108,12 +108,15 @@ chrome.runtime.onConnect.addListener((port) => { .collection('rooms') .doc(roomId) .collection('messages') + .orderBy('time') .onSnapshot( (snap) => { - if (snap) + if (snap) { + let messages = snap.docs.map((v) => ({ ...v.data(), id: v.id })); port.postMessage({ - messages: snap.docs.map((v) => ({ ...v.data(), id: v.id })), + messages, }); + } }, (err) => { port.postMessage({ isError: true, ...err }); diff --git a/src/Api.js b/src/Api.js index b024490..6a668ba 100644 --- a/src/Api.js +++ b/src/Api.js @@ -2,7 +2,8 @@ const API_HOST = window.location.href.startsWith('http://localhost') ? 'http://localhost:5001/watch-party-crx/us-central1/widgets' - : 'https://us-central1-watch-party-crx.cloudfunctions.net/widgets'; + : 'http://localhost:5001/watch-party-crx/us-central1/widgets'; +// : 'https://us-central1-watch-party-crx.cloudfunctions.net/widgets'; export const PLAYER_STATUS = { PLAYING: 'PLAYING', diff --git a/src/App.js b/src/App.js index d22f32c..f32dd12 100644 --- a/src/App.js +++ b/src/App.js @@ -7,6 +7,7 @@ import firebase from 'firebase/app'; import 'firebase/firestore'; import Inactive from './Inactive'; import { getUserUid } from './Api'; +import Chat from './Chat'; const darkTheme = createMuiTheme({ palette: { @@ -19,7 +20,7 @@ const darkTheme = createMuiTheme({ const Routes = (props) => ( - + ); diff --git a/src/Chat.js b/src/Chat.js index e433dd6..9bac938 100644 --- a/src/Chat.js +++ b/src/Chat.js @@ -28,7 +28,7 @@ import { goTo } from 'route-lite'; import Create from './Create'; import VideoListener from './VideoListener'; -const giphyFetch = new GiphyFetch('meKO7qbULHC9Q26DRGt2yZguIn3LB6z7'); +const giphyFetch = new GiphyFetch('ojJbIMUN6XRMn4mHiFFav3rMCpXUg8sq'); export default class Chat extends Component { constructor(props) { super(props); @@ -180,7 +180,7 @@ export default class Chat extends Component { name: window.localStorage.getItem('watchPartyUserName'), uid: window.localStorage.getItem('watchPartyUserUid'), text: message, - time: new Date().toISOString(), + time: new Date(), type: '', }; if (this.state.gif === true) data.type = 'giphy'; @@ -190,7 +190,7 @@ export default class Chat extends Component { }); } sendMessageInvoker(overrideMessage) { - if (overrideMessage) this.sendMessage(overrideMessage); + if (overrideMessage) console.log(overrideMessage); else { const trim = this.state.newMessage.replace(/^\s+|\s+$/g, ''); if (trim !== '') this.sendMessage(trim); @@ -199,7 +199,7 @@ export default class Chat extends Component { } gifClick(iGif, ev) { ev.preventDefault(); - this.sendMessageInvoker(iGif.images.original.url); + this.sendMessageInvoker(iGif); } getCarousel() { const trendingFetch = (offset) => giphyFetch.trending({ offset, limit: 5 }); @@ -242,9 +242,7 @@ export default class Chat extends Component {
- new Date(b).getTime() - new Date(a).getTime())} - /> +
console.log(e)); - document.body.appendChild(VideoPlayer); break; default: break;