v1.0.0-beta/amazon styling fix
This commit is contained in:
+73
-7
@@ -42,7 +42,7 @@ const authenticator = (req, res, next) => {
|
|||||||
const createRoom = async (req, res) => {
|
const createRoom = async (req, res) => {
|
||||||
const bodydata = JSON.parse(req.body);
|
const bodydata = JSON.parse(req.body);
|
||||||
console.log('Requested Create - UID - ', bodydata.uid);
|
console.log('Requested Create - UID - ', bodydata.uid);
|
||||||
if (!bodydata.userName) res.status(400).send('Missing user name');
|
if (!bodydata.userName) res.status(400).send({ message: 'Missing user name' });
|
||||||
const roomId = await admin
|
const roomId = await admin
|
||||||
.firestore()
|
.firestore()
|
||||||
.collection('rooms')
|
.collection('rooms')
|
||||||
@@ -54,6 +54,7 @@ const createRoom = async (req, res) => {
|
|||||||
})
|
})
|
||||||
.then((ref) => ref.id)
|
.then((ref) => ref.id)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
res.status(500).send({ message: 'Unable to start party.' });
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
await admin
|
await admin
|
||||||
@@ -66,6 +67,9 @@ const createRoom = async (req, res) => {
|
|||||||
name: '',
|
name: '',
|
||||||
text: `${bodydata.userName} started the party.`,
|
text: `${bodydata.userName} started the party.`,
|
||||||
time: new Date().toISOString(),
|
time: new Date().toISOString(),
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(`Failed to add system create party message : \n\t Room: ${roomId}`, err);
|
||||||
});
|
});
|
||||||
await admin
|
await admin
|
||||||
.firestore()
|
.firestore()
|
||||||
@@ -76,6 +80,12 @@ const createRoom = async (req, res) => {
|
|||||||
.set({
|
.set({
|
||||||
admin: true,
|
admin: true,
|
||||||
name: bodydata.userName,
|
name: bodydata.userName,
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(
|
||||||
|
`Failed to set admin when creating party : \n\t Room: ${roomId} \n\t User: ${bodydata.uid}`,
|
||||||
|
err
|
||||||
|
);
|
||||||
});
|
});
|
||||||
res.status(201).send({ roomId });
|
res.status(201).send({ roomId });
|
||||||
};
|
};
|
||||||
@@ -83,12 +93,12 @@ const createRoom = async (req, res) => {
|
|||||||
const joinRoom = async (req, res) => {
|
const joinRoom = async (req, res) => {
|
||||||
const bodydata = JSON.parse(req.body);
|
const bodydata = JSON.parse(req.body);
|
||||||
console.log('Requested Join - UID - ', bodydata.uid, '\n\tRoom - ', bodydata.roomId);
|
console.log('Requested Join - UID - ', bodydata.uid, '\n\tRoom - ', bodydata.roomId);
|
||||||
const exists = await admin
|
const [exists, roomSource] = await admin
|
||||||
.firestore()
|
.firestore()
|
||||||
.collection('rooms')
|
.collection('rooms')
|
||||||
.doc(bodydata.roomId)
|
.doc(bodydata.roomId)
|
||||||
.get()
|
.get()
|
||||||
.then((roomSnap) => roomSnap.exists);
|
.then((roomSnap) => [roomSnap.exists, roomSnap.exists ? roomSnap.data().player.source : '']);
|
||||||
const userExists = await admin
|
const userExists = await admin
|
||||||
.firestore()
|
.firestore()
|
||||||
.collection('rooms')
|
.collection('rooms')
|
||||||
@@ -97,8 +107,15 @@ const joinRoom = async (req, res) => {
|
|||||||
.doc(bodydata.uid)
|
.doc(bodydata.uid)
|
||||||
.get()
|
.get()
|
||||||
.then((userSnap) => userSnap.exists);
|
.then((userSnap) => userSnap.exists);
|
||||||
if (userExists) res.status(200).send({ roomId: bodydata.roomId });
|
if (userExists && exists && roomSource === bodydata.source)
|
||||||
else if (!userExists && exists && bodydata.roomId && bodydata.userName) {
|
res.status(200).send({ roomId: bodydata.roomId });
|
||||||
|
else if (
|
||||||
|
!userExists &&
|
||||||
|
exists &&
|
||||||
|
bodydata.roomId &&
|
||||||
|
bodydata.userName &&
|
||||||
|
roomSource === bodydata.source
|
||||||
|
) {
|
||||||
await admin
|
await admin
|
||||||
.firestore()
|
.firestore()
|
||||||
.collection('rooms')
|
.collection('rooms')
|
||||||
@@ -109,6 +126,12 @@ const joinRoom = async (req, res) => {
|
|||||||
name: '',
|
name: '',
|
||||||
text: `${bodydata.userName} joined the party.`,
|
text: `${bodydata.userName} joined the party.`,
|
||||||
time: new Date().toISOString(),
|
time: new Date().toISOString(),
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(
|
||||||
|
`Failed to add system join party message : \n\t Room: ${roomId} \n\t ${bodydata.uid}`,
|
||||||
|
err
|
||||||
|
);
|
||||||
});
|
});
|
||||||
await admin
|
await admin
|
||||||
.firestore()
|
.firestore()
|
||||||
@@ -119,18 +142,44 @@ const joinRoom = async (req, res) => {
|
|||||||
.set({
|
.set({
|
||||||
admin: false,
|
admin: false,
|
||||||
name: bodydata.userName,
|
name: bodydata.userName,
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(
|
||||||
|
`Failed to set admin when joining party : \n\t Room: ${roomId} \n\t User: ${bodydata.uid}`,
|
||||||
|
err
|
||||||
|
);
|
||||||
});
|
});
|
||||||
await admin.firestore().collection('rooms').doc(bodydata.roomId).update({
|
await admin
|
||||||
|
.firestore()
|
||||||
|
.collection('rooms')
|
||||||
|
.doc(bodydata.roomId)
|
||||||
|
.update({
|
||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(
|
||||||
|
`Failed to set updated time when joining party : \n\t Room: ${roomId} \n\t User: ${bodydata.uid}`,
|
||||||
|
err
|
||||||
|
);
|
||||||
});
|
});
|
||||||
res.status(200).send({ roomId: bodydata.roomId });
|
res.status(200).send({ roomId: bodydata.roomId });
|
||||||
} else if (!userExists && !bodydata.userName)
|
} else if (!userExists && !bodydata.userName)
|
||||||
res.status(400).send({ message: 'Missing user name' });
|
res.status(400).send({ message: 'Missing user name' });
|
||||||
|
else if (exists && roomSource !== bodydata.source)
|
||||||
|
res.status(417).send({ message: `This party is on ${roomSource}` });
|
||||||
else res.status(404).send({ message: 'Party Not Found' });
|
else res.status(404).send({ message: 'Party Not Found' });
|
||||||
};
|
};
|
||||||
|
|
||||||
const sendMessage = async (req, res) => {
|
const sendMessage = async (req, res) => {
|
||||||
const { name, text, time, uid, roomId } = JSON.parse(req.body);
|
const { name, text, time, uid, roomId } = JSON.parse(req.body);
|
||||||
|
|
||||||
|
const roomExists = await admin
|
||||||
|
.firestore()
|
||||||
|
.collection('rooms')
|
||||||
|
.doc(roomId)
|
||||||
|
.get()
|
||||||
|
.then((roomSnap) => roomSnap.exists);
|
||||||
|
if (roomExists) {
|
||||||
await admin
|
await admin
|
||||||
.firestore()
|
.firestore()
|
||||||
.collection('rooms')
|
.collection('rooms')
|
||||||
@@ -147,6 +196,9 @@ const sendMessage = async (req, res) => {
|
|||||||
updatedAt: new Date().toISOString(),
|
updatedAt: new Date().toISOString(),
|
||||||
});
|
});
|
||||||
res.status(200).send({ message: 'Sent a message' });
|
res.status(200).send({ message: 'Sent a message' });
|
||||||
|
} else {
|
||||||
|
res.status(404).send({ message: 'Looks like this party is over' });
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const leaveRoom = async (req, res) => {
|
const leaveRoom = async (req, res) => {
|
||||||
@@ -158,7 +210,12 @@ const leaveRoom = async (req, res) => {
|
|||||||
.collection('users')
|
.collection('users')
|
||||||
.doc(req.params.uid)
|
.doc(req.params.uid)
|
||||||
.delete()
|
.delete()
|
||||||
.catch((err) => res.status(500).send(err));
|
.catch((err) =>
|
||||||
|
console.error(
|
||||||
|
`Failed to remove user from party : \n\t Room: ${req.params.rid} \n\t User: ${req.params.uid}`,
|
||||||
|
err
|
||||||
|
)
|
||||||
|
);
|
||||||
res.status(200).send({ message: 'Left the party' });
|
res.status(200).send({ message: 'Left the party' });
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -297,3 +354,12 @@ app.delete('/delete/:rid', deleteRoom);
|
|||||||
app.post('/updatePlayer', updatePlayer);
|
app.post('/updatePlayer', updatePlayer);
|
||||||
|
|
||||||
exports.widgets = functions.https.onRequest(app);
|
exports.widgets = functions.https.onRequest(app);
|
||||||
|
|
||||||
|
exports.scheduledCleanUp = functions.pubsub.schedule('every 1 hour').onRun(async () => {
|
||||||
|
const roomsList = await admin
|
||||||
|
.firestore()
|
||||||
|
.collection('rooms')
|
||||||
|
.listDocuments()
|
||||||
|
.then((rL) => rL.map(async (r) => await r.get()));
|
||||||
|
console.log(roomsList);
|
||||||
|
});
|
||||||
|
|||||||
@@ -81,7 +81,9 @@ chrome.runtime.onConnect.addListener((port) => {
|
|||||||
port.postMessage(snap.data());
|
port.postMessage(snap.data());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(err) => {}
|
(err) => {
|
||||||
|
port.postMessage({ isError: true, ...err });
|
||||||
|
}
|
||||||
);
|
);
|
||||||
firebase
|
firebase
|
||||||
.firestore()
|
.firestore()
|
||||||
@@ -97,7 +99,9 @@ chrome.runtime.onConnect.addListener((port) => {
|
|||||||
port.postMessage({ admin: isAdmin });
|
port.postMessage({ admin: isAdmin });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(err) => {}
|
(err) => {
|
||||||
|
port.postMessage({ isError: true, ...err });
|
||||||
|
}
|
||||||
);
|
);
|
||||||
firebase
|
firebase
|
||||||
.firestore()
|
.firestore()
|
||||||
@@ -110,7 +114,9 @@ chrome.runtime.onConnect.addListener((port) => {
|
|||||||
if (snap)
|
if (snap)
|
||||||
port.postMessage({ messages: snap.docs.map((v) => ({ ...v.data(), id: v.id })) });
|
port.postMessage({ messages: snap.docs.map((v) => ({ ...v.data(), id: v.id })) });
|
||||||
},
|
},
|
||||||
(err) => {}
|
(err) => {
|
||||||
|
port.postMessage({ isError: true, ...err });
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+27
-3
@@ -64,6 +64,11 @@ export default class Chat extends Component {
|
|||||||
roomId: window.localStorage.getItem('watchPartyRoomId'),
|
roomId: window.localStorage.getItem('watchPartyRoomId'),
|
||||||
});
|
});
|
||||||
this.port.onMessage.addListener((response) => {
|
this.port.onMessage.addListener((response) => {
|
||||||
|
if (response.isError === true) {
|
||||||
|
this.props.notify('Uh oh. Got lost from the party.');
|
||||||
|
goTo(Create, this.props);
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.setState(response);
|
this.setState(response);
|
||||||
if (response.player && this.state.localPlayer.status !== response.player.status) {
|
if (response.player && this.state.localPlayer.status !== response.player.status) {
|
||||||
if (response.player.source !== getPlayerSource()) {
|
if (response.player.source !== getPlayerSource()) {
|
||||||
@@ -104,6 +109,10 @@ export default class Chat extends Component {
|
|||||||
time,
|
time,
|
||||||
source,
|
source,
|
||||||
},
|
},
|
||||||
|
}).catch((err) => {
|
||||||
|
this.props.updateLoading(false);
|
||||||
|
this.props.notify(err.message || err.statusText);
|
||||||
|
console.error('Sync Party API error', err);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.mVideoListener.start();
|
this.mVideoListener.start();
|
||||||
@@ -115,11 +124,17 @@ export default class Chat extends Component {
|
|||||||
const data = {
|
const data = {
|
||||||
roomId: window.localStorage.getItem('watchPartyRoomId'),
|
roomId: window.localStorage.getItem('watchPartyRoomId'),
|
||||||
};
|
};
|
||||||
DeleteRoomApi(data).then((res) => {
|
DeleteRoomApi(data)
|
||||||
|
.then((res) => {
|
||||||
this.props.notify('Ended party');
|
this.props.notify('Ended party');
|
||||||
window.localStorage.removeItem('watchPartyRoomId');
|
window.localStorage.removeItem('watchPartyRoomId');
|
||||||
goTo(Create, this.props);
|
goTo(Create, this.props);
|
||||||
this.props.updateLoading(false);
|
this.props.updateLoading(false);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
this.props.updateLoading(false);
|
||||||
|
this.props.notify(err.message || err.statusText);
|
||||||
|
console.error('End Party API error', err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
leaveParty() {
|
leaveParty() {
|
||||||
@@ -129,11 +144,17 @@ export default class Chat extends Component {
|
|||||||
roomId: window.localStorage.getItem('watchPartyRoomId'),
|
roomId: window.localStorage.getItem('watchPartyRoomId'),
|
||||||
uid: window.localStorage.getItem('watchPartyUserUid'),
|
uid: window.localStorage.getItem('watchPartyUserUid'),
|
||||||
};
|
};
|
||||||
LeaveRoomApi(data).then((res) => {
|
LeaveRoomApi(data)
|
||||||
|
.then((res) => {
|
||||||
this.props.notify('Left party');
|
this.props.notify('Left party');
|
||||||
window.localStorage.removeItem('watchPartyRoomId');
|
window.localStorage.removeItem('watchPartyRoomId');
|
||||||
goTo(Create, this.props);
|
goTo(Create, this.props);
|
||||||
this.props.updateLoading(false);
|
this.props.updateLoading(false);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
this.props.updateLoading(false);
|
||||||
|
this.props.notify(err.message || err.statusText);
|
||||||
|
console.error('End Party API error', err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
shareParty() {
|
shareParty() {
|
||||||
@@ -153,7 +174,10 @@ export default class Chat extends Component {
|
|||||||
text: message,
|
text: message,
|
||||||
time: new Date().toISOString(),
|
time: new Date().toISOString(),
|
||||||
};
|
};
|
||||||
SendMessageApi(data);
|
SendMessageApi(data).catch((err) => {
|
||||||
|
this.props.notify(err.message || err.statusText);
|
||||||
|
console.error('Send Message API error', err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
const { admin, name, messages, newMessage } = this.state;
|
const { admin, name, messages, newMessage } = this.state;
|
||||||
|
|||||||
+4
-3
@@ -32,13 +32,14 @@ const joinRoom = async (data) => {
|
|||||||
const apidata = {
|
const apidata = {
|
||||||
roomId: data.joinName.trim(),
|
roomId: data.joinName.trim(),
|
||||||
userName: data.name.trim(),
|
userName: data.name.trim(),
|
||||||
|
source: getPlayerSource(),
|
||||||
};
|
};
|
||||||
const confirmedRoomId = await JoinRoomApi(apidata)
|
const confirmedRoomId = await JoinRoomApi(apidata)
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
.then((res) => res.roomId)
|
.then((res) => res.roomId)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
data.props.updateLoading(false);
|
data.props.updateLoading(false);
|
||||||
data.props.notify(err.statusText);
|
data.props.notify(err.message || err.statusText);
|
||||||
console.error('Join Room API error', err);
|
console.error('Join Room API error', err);
|
||||||
});
|
});
|
||||||
if (confirmedRoomId && confirmedRoomId === apidata.roomId) {
|
if (confirmedRoomId && confirmedRoomId === apidata.roomId) {
|
||||||
@@ -86,12 +87,12 @@ const createRoom = async (data) => {
|
|||||||
goTo(Chat, data.props);
|
goTo(Chat, data.props);
|
||||||
} else {
|
} else {
|
||||||
data.props.updateLoading(false);
|
data.props.updateLoading(false);
|
||||||
data.props.notify(res.statusText);
|
data.props.notify(res.message || res.statusText);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
data.props.updateLoading(false);
|
data.props.updateLoading(false);
|
||||||
data.props.notify(err.statusText);
|
data.props.notify(err.message || err.statusText);
|
||||||
console.error('Create Room API error', err);
|
console.error('Create Room API error', err);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,6 +31,28 @@ body.amazon-prime #party-routes-wrapper {
|
|||||||
width: 35% !important;
|
width: 35% !important;
|
||||||
height: 100% !important;
|
height: 100% !important;
|
||||||
}
|
}
|
||||||
|
/* AMAZON STYLING FIX */
|
||||||
|
body.amazon-prime input,
|
||||||
|
body.amazon-prime textarea {
|
||||||
|
background-color: inherit !important;
|
||||||
|
border: initial !important;
|
||||||
|
box-shadow: none !important;
|
||||||
|
}
|
||||||
|
body.amazon-prime input.MuiInputBase-input {
|
||||||
|
height: 1.1876em !important;
|
||||||
|
padding: 6px 0 7px !important;
|
||||||
|
}
|
||||||
|
body.amazon-prime input.MuiFilledInput-inputAdornedEnd {
|
||||||
|
padding-right: 0 !important;
|
||||||
|
}
|
||||||
|
body.amazon-prime input.MuiFilledInput-input {
|
||||||
|
padding: 27px 12px 10px !important;
|
||||||
|
}
|
||||||
|
body.amazon-prime input:focus,
|
||||||
|
body.amazon-prime textarea:focus {
|
||||||
|
border: none !important;
|
||||||
|
box-shadow: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
@keyframes backgroundpulse {
|
@keyframes backgroundpulse {
|
||||||
0% {
|
0% {
|
||||||
|
|||||||
Reference in New Issue
Block a user