v1.3.0-beta/UI redone

This commit is contained in:
2020-05-31 00:35:24 -04:00
parent fba32fd7d1
commit aa15c4eb30
21 changed files with 676 additions and 333 deletions
+14 -4
View File
@@ -1,9 +1,9 @@
/*global chrome*/
const API_HOST = window.location.href.startsWith('http://localhost')
? 'http://localhost:5001/watch-party-crx/us-central1/widgets'
: // : 'http://localhost:5001/watch-party-crx/us-central1/widgets';
'https://us-central1-watch-party-crx.cloudfunctions.net/widgets';
? 'http://localhost:5000/watch-party-crx/us-central1/widgets'
: // : 'https://us-central1-watch-party-crx.cloudfunctions.net/widgets';
'http://localhost:5000/watch-party-crx/us-central1/widgets';
export const PLAYER_STATUS = {
PLAYING: 'PLAYING',
@@ -32,6 +32,16 @@ export const getPlayerSource = () => {
if (HREF.startsWith(PLAYER_SOURCE.LOCAL)) return PLAYER_SOURCE.LOCAL;
};
export const LocalData = () => {
return JSON.parse(window.localStorage.getItem('WatchParty')) || {};
};
export const updateLocalData = (data) => {
window.localStorage.setItem('WatchParty', JSON.stringify(Object.assign({}, LocalData(), data)));
};
export const emptyLocalData = () => window.localStorage.setItem('WatchParty', undefined);
export const getUserUid = async () =>
new Promise((resolve, reject) => {
chrome.runtime.sendMessage(
@@ -40,7 +50,7 @@ export const getUserUid = async () =>
},
(response) => {
const { uid } = response;
window.localStorage.setItem('watchPartyUserUid', uid);
updateLocalData({ userUid: uid });
resolve(uid);
}
);