From c649ca12112860339cf642fb7dbd1f2aa5fdfedf Mon Sep 17 00:00:00 2001 From: Matthew Grove Date: Thu, 25 Nov 2021 21:57:50 +0000 Subject: [PATCH] Add ability to search public sets! Also bump version Public sets are now paginated and searchable, on a separate search page --- src/App.js | 4 + src/LoggedInHome.js | 74 ++------- src/SearchSets.js | 366 +++++++++++++++++++++++++++++++++++++++++ src/css/SearchSets.css | 20 +++ 4 files changed, 405 insertions(+), 59 deletions(-) create mode 100644 src/SearchSets.js create mode 100644 src/css/SearchSets.css diff --git a/src/App.js b/src/App.js index 62ffbcb..7eb7df4 100644 --- a/src/App.js +++ b/src/App.js @@ -19,6 +19,7 @@ import MistakesHistory from "./MistakesHistory"; import TermsOfService from "./TermsOfService"; import PrivacyPolicy from "./PrivacyPolicy"; import Button from "./Button"; +import SearchSets from './SearchSets'; import { CheckRounded as CheckRoundedIcon } from "@material-ui/icons"; import Loader from "./puff-loader.svg"; @@ -294,6 +295,9 @@ class App extends React.Component { + + + diff --git a/src/LoggedInHome.js b/src/LoggedInHome.js index 0faa5c8..45c9954 100644 --- a/src/LoggedInHome.js +++ b/src/LoggedInHome.js @@ -1,7 +1,7 @@ import React from 'react'; import NavBar from "./NavBar"; import { Link } from "react-router-dom"; -import { TimelineRounded as TimelineRoundedIcon, ExitToAppRounded as ExitToAppRoundedIcon, HistoryRounded as HistoryRoundedIcon, SettingsRounded as SettingsRoundedIcon, PersonRounded as PersonRoundedIcon, PublicRounded as PublicRoundedIcon, GroupRounded as GroupRoundedIcon, AddRounded as AddRoundedIcon, SwapHorizRounded as SwapHorizRoundedIcon, PeopleRounded as PeopleRoundedIcon, DeleteRounded as DeleteRoundedIcon, QuestionAnswerRounded as QuestionAnswerRoundedIcon } from "@material-ui/icons"; +import { TimelineRounded as TimelineRoundedIcon, ExitToAppRounded as ExitToAppRoundedIcon, HistoryRounded as HistoryRoundedIcon, SettingsRounded as SettingsRoundedIcon, PersonRounded as PersonRoundedIcon, GroupRounded as GroupRoundedIcon, AddRounded as AddRoundedIcon, SwapHorizRounded as SwapHorizRoundedIcon, PeopleRounded as PeopleRoundedIcon, DeleteRounded as DeleteRoundedIcon, QuestionAnswerRounded as QuestionAnswerRoundedIcon, SearchRounded as SearchRoundedIcon } from "@material-ui/icons"; import Checkbox from '@material-ui/core/Checkbox'; import Xarrow from 'react-xarrows'; @@ -93,11 +93,6 @@ export default withRouter(class LoggedInHome extends React.Component { const userSetsRef = this.state.db.collection("sets") .where("owner", "==", this.state.user.uid) .orderBy("title"); - const publicSetsRef = this.state.db.collection("sets") - .where("public", "==", true) - .where("owner", "!=", this.state.user.uid) - .orderBy("owner") - .orderBy("title"); const userGroupsRef = this.state.db.collection("users") .doc(this.state.user.uid) .collection("groups"); @@ -115,12 +110,6 @@ export default withRouter(class LoggedInHome extends React.Component { userSetsQuerySnapshot.docs.map((doc) => newState.selections[doc.id] = false); - }); - const publicSetsQuery = publicSetsRef.get().then((publicSetsQuerySnapshot) => { - newState.publicSets = publicSetsQuerySnapshot.docs; - - publicSetsQuerySnapshot.docs.map((doc) => newState.selections[doc.id] = false); - }); const userGroupsQuery = userGroupsRef.get().then(async (userGroupsQuerySnapshot) => { newState.user.groups = []; @@ -179,7 +168,6 @@ export default withRouter(class LoggedInHome extends React.Component { Promise.all([ userSetsQuery, - publicSetsQuery, userGroupsQuery, progressQuery ]).then(() => { @@ -378,22 +366,23 @@ export default withRouter(class LoggedInHome extends React.Component { > Test ({Object.values(this.state.selections).filter(x => x === true).length}) - - Groups - { (!this.props.page.loaded() || (this.state.userSets && this.state.userSets.length > 0)) && + > My Sets } - } className="button--round" title="Create set"> + } className="button--round" title="Create set"> + } className="button--round" title="Search sets"> + } className="button--round" title="Groups"> + +
+ } className="button--round buttons--mobile" title="Create set"> + } className="button--round" title="Search sets"> + } className="button--round" title="Groups">
- } className="button--round buttons--mobile" title="Create set">
- - Groups - { this.state.userSets && this.state.userSets.length > 0 && {this.state.userSets && this.state.userSets.length > 0 &&
-

Personal Sets

+ +

My Sets

+
{this.state.userSets .sort((a, b) => { @@ -561,38 +549,6 @@ export default withRouter(class LoggedInHome extends React.Component {
)} - {this.state.publicSets && this.state.publicSets.length > 0 && -
-

Public Sets

-
- {this.state.publicSets - .sort((a, b) => { - if (a.data().title < b.data().title) { - return -1; - } - if (a.data().title > b.data().title) { - return 1; - } - return 0; - }).map(set => -
- -
- ) - } -
-
- }