This commit is contained in:
Ayushya Amitabh
2020-04-17 14:37:39 -04:00
parent 1acbca3bf0
commit 15679cd001
12 changed files with 439 additions and 190 deletions
+32 -1
View File
@@ -5,6 +5,27 @@ 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';
export const PLAYER_STATUS = {
PLAYING: 'PLAYING',
PAUSED: 'PAUSED',
NOT_PLAYING: 'NOT_PLAYING',
};
export const PLAYER_SOURCE = {
NETFLIX: 'https://www.netflix.',
AMAZON: 'https://www.amazon.',
HULU: 'https://www.hulu.',
LOCAL: 'http://localhost',
};
export const getPlayerSource = () => {
const HREF = window.location.href;
if (HREF.startsWith(PLAYER_SOURCE.NETFLIX)) return PLAYER_SOURCE.NETFLIX;
if (HREF.startsWith(PLAYER_SOURCE.HULU)) return PLAYER_SOURCE.HULU;
if (HREF.startsWith(PLAYER_SOURCE.AMAZON)) return PLAYER_SOURCE.AMAZON;
if (HREF.startsWith(PLAYER_SOURCE.LOCAL)) return PLAYER_SOURCE.LOCAL;
};
export const isAuthed = () => true && firebase.auth().currentUser;
export const doAuth = () => firebase.auth().signInAnonymously();
@@ -42,7 +63,7 @@ export const SendMessageApi = async (data) => {
if (!isAuthed()) await doAuth();
return fetcher({
ENDPOINT: 'message',
METHOD: 'post',
METHOD: 'POST',
body: JSON.stringify(data),
});
};
@@ -62,3 +83,13 @@ export const DeleteRoomApi = async (data) => {
METHOD: 'DELETE',
});
};
export const UpdatePlayerApi = async (data) => {
if (isAuthed()) {
return fetcher({
ENDPOINT: 'updatePlayer',
METHOD: 'POST',
body: JSON.stringify(data),
});
}
};