62
src/App.js
62
src/App.js
@@ -26,7 +26,6 @@ import "firebase/auth";
|
||||
import "firebase/functions";
|
||||
import "firebase/app-check";
|
||||
import "firebase/firestore";
|
||||
import "firebase/analytics";
|
||||
|
||||
// TODO: app check debug token set in index.html - remove before deploy
|
||||
|
||||
@@ -72,7 +71,6 @@ const themes = [
|
||||
];
|
||||
|
||||
const db = firebase.firestore();
|
||||
const analytics = firebase.analytics();
|
||||
|
||||
class App extends React.Component {
|
||||
constructor(props) {
|
||||
@@ -90,29 +88,17 @@ class App extends React.Component {
|
||||
user: userData,
|
||||
};
|
||||
|
||||
if (userData) {
|
||||
if (firebase.auth().currentUser.metadata.creationTime ===
|
||||
firebase.auth().currentUser.metadata.lastSignInTime) {
|
||||
analytics.logEvent("sign_up", {
|
||||
method: userData.providerId,
|
||||
});
|
||||
} else {
|
||||
analytics.logEvent("login", {
|
||||
method: userData.providerId,
|
||||
});
|
||||
}
|
||||
await firebase.firestore()
|
||||
.collection("users")
|
||||
.doc(userData.uid)
|
||||
.get()
|
||||
.then((userDoc) => {
|
||||
newState.sound = userDoc.data().sound;
|
||||
newState.theme = userDoc.data().theme;
|
||||
}).catch((error) => {
|
||||
newState.sound = true;
|
||||
newState.theme = "default";
|
||||
});
|
||||
}
|
||||
if (userData) await firebase.firestore()
|
||||
.collection("users")
|
||||
.doc(userData.uid)
|
||||
.get()
|
||||
.then((userDoc) => {
|
||||
newState.sound = userDoc.data().sound;
|
||||
newState.theme = userDoc.data().theme;
|
||||
}).catch((error) => {
|
||||
newState.sound = true;
|
||||
newState.theme = "default";
|
||||
});
|
||||
|
||||
this.setState(newState);
|
||||
});
|
||||
@@ -217,40 +203,40 @@ class App extends React.Component {
|
||||
<>
|
||||
<Switch>
|
||||
<Route path="/" exact>
|
||||
<LoggedInHome db={db} firebase={firebase} functions={functions} user={this.state.user} logEvent={analytics.logEvent} />
|
||||
<LoggedInHome db={db} firebase={firebase} functions={functions} user={this.state.user} />
|
||||
</Route>
|
||||
<Route path="/sets/:setId" exact>
|
||||
<SetPage db={db} functions={functions} user={this.state.user} logEvent={analytics.logEvent} />
|
||||
<SetPage db={db} functions={functions} user={this.state.user} />
|
||||
</Route>
|
||||
<Route path="/groups" exact>
|
||||
<UserGroups db={db} functions={functions} user={this.state.user} logEvent={analytics.logEvent} />
|
||||
<UserGroups db={db} functions={functions} user={this.state.user} />
|
||||
</Route>
|
||||
<Route path="/groups/:groupId" exact>
|
||||
<GroupPage db={db} functions={functions} user={this.state.user} logEvent={analytics.logEvent} />
|
||||
<GroupPage db={db} functions={functions} user={this.state.user} />
|
||||
</Route>
|
||||
<Route path="/settings">
|
||||
<Settings db={db} user={this.state.user} sound={this.state.sound} handleSoundChange={this.handleSoundChange} theme={this.state.theme} handleThemeChange={this.handleThemeChange} themes={themes} logEvent={analytics.logEvent} />
|
||||
<Settings db={db} user={this.state.user} sound={this.state.sound} handleSoundChange={this.handleSoundChange} theme={this.state.theme} handleThemeChange={this.handleThemeChange} themes={themes} />
|
||||
</Route>
|
||||
<Route path="/progress/:progressId" exact>
|
||||
<Progress db={db} functions={functions} user={this.state.user} sound={this.state.sound} handleSoundChange={this.handleSoundChange} theme={this.state.theme} handleThemeChange={this.handleThemeChange} themes={themes} logEvent={analytics.logEvent} />
|
||||
<Progress db={db} functions={functions} user={this.state.user} sound={this.state.sound} handleSoundChange={this.handleSoundChange} theme={this.state.theme} handleThemeChange={this.handleThemeChange} themes={themes} />
|
||||
</Route>
|
||||
<Route path="/create-set" exact>
|
||||
<CreateSet db={db} user={this.state.user} logEvent={analytics.logEvent} />
|
||||
<CreateSet db={db} user={this.state.user} />
|
||||
</Route>
|
||||
<Route path="/my-sets" exact>
|
||||
<UserSets db={db} functions={functions} user={this.state.user} logEvent={analytics.logEvent} />
|
||||
<UserSets db={db} functions={functions} user={this.state.user} />
|
||||
</Route>
|
||||
<Route path="/sets/:setId/edit" exact>
|
||||
<EditSet db={db} user={this.state.user} logEvent={analytics.logEvent} />
|
||||
<EditSet db={db} user={this.state.user} />
|
||||
</Route>
|
||||
<Route path="/history" exact>
|
||||
<History db={db} user={this.state.user} logEvent={analytics.logEvent} />
|
||||
<History db={db} user={this.state.user} />
|
||||
</Route>
|
||||
<Route path="/tos" exact>
|
||||
<TermsOfService logEvent={analytics.logEvent} />
|
||||
<TermsOfService />
|
||||
</Route>
|
||||
<Route path="/privacy" exact>
|
||||
<PrivacyPolicy logEvent={analytics.logEvent} />
|
||||
<PrivacyPolicy />
|
||||
</Route>
|
||||
<Redirect from="/login" to="/" />
|
||||
<Route>
|
||||
@@ -265,7 +251,7 @@ class App extends React.Component {
|
||||
<Home db={db} />
|
||||
</Route>
|
||||
<Route path="/login">
|
||||
<Login db={db} firebase={firebase} logEvent={analytics.logEvent} />
|
||||
<Login db={db} firebase={firebase} />
|
||||
</Route>
|
||||
<Route>
|
||||
<Error404 />
|
||||
|
||||
@@ -47,11 +47,6 @@ export default withRouter(class CreateSet extends React.Component {
|
||||
componentDidMount() {
|
||||
document.title = "Create Set | Parandum";
|
||||
this.setNameInput.focus();
|
||||
|
||||
this.props.logEvent("select_content", {
|
||||
content_type: "main_page",
|
||||
item_id: "create_set",
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
@@ -109,11 +109,6 @@ export default withRouter(class EditSet extends Component {
|
||||
setInaccessible: true,
|
||||
});
|
||||
});
|
||||
|
||||
this.props.logEvent("select_content", {
|
||||
content_type: "edit_set",
|
||||
item_id: this.props.match.params.setId,
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount = () => {
|
||||
|
||||
@@ -3,7 +3,7 @@ import NavBar from './NavBar';
|
||||
import Footer from "./Footer";
|
||||
import { HomeRounded as HomeRoundedIcon } from "@material-ui/icons";
|
||||
|
||||
export default function Error404(props) {
|
||||
export default function PageNotFound() {
|
||||
const navbarItems = [
|
||||
{
|
||||
type: "link",
|
||||
@@ -15,11 +15,6 @@ export default function Error404(props) {
|
||||
|
||||
document.title = "Error 404 | Parandum";
|
||||
|
||||
props.logEvent("select_content", {
|
||||
content_type: "main_page",
|
||||
item_id: "error_404",
|
||||
});
|
||||
|
||||
return (
|
||||
<div>
|
||||
<NavBar items={navbarItems}/>
|
||||
|
||||
@@ -119,11 +119,6 @@ export default withRouter(class GroupPage extends Component {
|
||||
this.setState(newState);
|
||||
});
|
||||
});
|
||||
|
||||
this.props.logEvent("select_content", {
|
||||
content_type: "group",
|
||||
item_id: this.props.match.params.groupId,
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
@@ -77,11 +77,6 @@ export default class History extends Component {
|
||||
}).catch((error) => {
|
||||
console.log(`Couldn't retrieve progress history: ${error}`);
|
||||
});
|
||||
|
||||
this.props.logEvent("select_content", {
|
||||
content_type: "main_page",
|
||||
item_id: "history",
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
@@ -160,11 +160,6 @@ export default withRouter(class LoggedInHome extends React.Component {
|
||||
]).then(() => {
|
||||
this.setState(newState);
|
||||
});
|
||||
|
||||
this.props.logEvent("select_content", {
|
||||
content_type: "main_page",
|
||||
item_id: "logged_in_home",
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
@@ -26,11 +26,6 @@ export default function Login(props) {
|
||||
document.body.style.overflow = "hidden";
|
||||
document.title = "Login | Parandum";
|
||||
|
||||
props.logEvent("select_content", {
|
||||
content_type: "main_page",
|
||||
item_id: "login",
|
||||
});
|
||||
|
||||
return (
|
||||
<>
|
||||
<Home />
|
||||
|
||||
@@ -3,7 +3,7 @@ import { HomeRounded as HomeRoundedIcon } from "@material-ui/icons";
|
||||
import NavBar from "./NavBar";
|
||||
import Footer from "./Footer";
|
||||
|
||||
export default function PrivacyPolicy(props) {
|
||||
export default function PrivacyPolicy() {
|
||||
const navbarItems = [
|
||||
{
|
||||
type: "link",
|
||||
@@ -13,11 +13,6 @@ export default function PrivacyPolicy(props) {
|
||||
}
|
||||
];
|
||||
|
||||
props.logEvent("select_content", {
|
||||
content_type: "main_page",
|
||||
item_id: "privacy",
|
||||
});
|
||||
|
||||
return (
|
||||
<div>
|
||||
<NavBar items={navbarItems} />
|
||||
|
||||
@@ -182,11 +182,6 @@ export default withRouter(class Progress extends React.Component {
|
||||
this.setState(newState, () => {
|
||||
if (!setDone) this.answerInput.focus()
|
||||
});
|
||||
|
||||
this.props.logEvent("select_content", {
|
||||
content_type: "progress",
|
||||
item_id: this.props.match.params.progressId,
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
@@ -95,11 +95,6 @@ export default withRouter(class SetPage extends React.Component {
|
||||
});
|
||||
console.log(`Can't access set: ${error}`);
|
||||
});
|
||||
|
||||
this.props.logEvent("select_content", {
|
||||
content_type: "set",
|
||||
item_id: this.props.match.params.setId,
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
@@ -37,11 +37,6 @@ export default withRouter(class Settings extends Component {
|
||||
|
||||
componentDidMount() {
|
||||
document.title = "Settings | Parandum";
|
||||
|
||||
this.props.logEvent("select_content", {
|
||||
content_type: "main_page",
|
||||
item_id: "settings",
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
@@ -4,7 +4,7 @@ import NavBar from "./NavBar";
|
||||
import Footer from "./Footer";
|
||||
import { Link } from "react-router-dom";
|
||||
|
||||
export default function TermsOfService(props) {
|
||||
export default function TermsOfService() {
|
||||
const navbarItems = [
|
||||
{
|
||||
type: "link",
|
||||
@@ -14,11 +14,6 @@ export default function TermsOfService(props) {
|
||||
}
|
||||
];
|
||||
|
||||
props.logEvent("select_content", {
|
||||
content_type: "main_page",
|
||||
item_id: "tos",
|
||||
});
|
||||
|
||||
return (
|
||||
<div>
|
||||
<NavBar items={navbarItems} />
|
||||
|
||||
@@ -76,11 +76,6 @@ export default withRouter(class UserGroups extends Component {
|
||||
|
||||
this.setState(newState);
|
||||
});
|
||||
|
||||
this.props.logEvent("select_content", {
|
||||
content_type: "main_page",
|
||||
item_id: "groups",
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
@@ -117,9 +112,6 @@ export default withRouter(class UserGroups extends Component {
|
||||
|
||||
this.state.functions.createGroup(this.state.groupName)
|
||||
.then((result) => {
|
||||
this.props.logEvent("join_group", {
|
||||
group_id: result.data,
|
||||
});
|
||||
this.props.history.push(`/groups/${result.data}`);
|
||||
this.stopCreateGroupLoading();
|
||||
}).catch((error) => {
|
||||
@@ -144,9 +136,6 @@ export default withRouter(class UserGroups extends Component {
|
||||
.set({
|
||||
role: "member",
|
||||
}).then(() => {
|
||||
this.props.logEvent("join_group", {
|
||||
group_id: joinCodeDoc.data().group,
|
||||
});
|
||||
this.props.history.push(`/groups/${joinCodeDoc.data().group}`);
|
||||
this.stopJoinGroupLoading();
|
||||
});
|
||||
|
||||
@@ -51,11 +51,6 @@ export default withRouter(class UserSets extends Component {
|
||||
userSets: querySnapshot.docs,
|
||||
})
|
||||
});
|
||||
|
||||
this.props.logEvent("select_content", {
|
||||
content_type: "main_page",
|
||||
item_id: "sets",
|
||||
});
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
|
||||
Reference in New Issue
Block a user