From 50c2dfa9b6abd1c7301d6b9972a5089cf17abe94 Mon Sep 17 00:00:00 2001 From: kyle hoell Date: Thu, 3 Dec 2020 17:21:45 -0500 Subject: [PATCH] fixed search and loading more for search --- src/actions/files.js | 2 ++ src/components/Header/index.js | 5 ++++- src/components/Homepage/index.js | 8 ++++++-- src/components/MainSection/MainSection.js | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/actions/files.js b/src/actions/files.js index 55ea36d..363974c 100644 --- a/src/actions/files.js +++ b/src/actions/files.js @@ -316,6 +316,8 @@ export const startLoadMoreFiles = (parent="/", sortby="DEFAULT", search="", star return (dispatch) => { + console.log("search", search) + //dispatch(setLoading(true)) dispatch(setLoadingMoreItems(true)); diff --git a/src/components/Header/index.js b/src/components/Header/index.js index f476b3f..714c878 100644 --- a/src/components/Header/index.js +++ b/src/components/Header/index.js @@ -48,10 +48,13 @@ class HeaderContainer extends React.Component { } searchOnChange = (e) => { - + const value = e.target.value; this.searchValue = value; + console.log("search on change", value); + + this.props.dispatch(setSearch(value)) this.searchSuggested() } diff --git a/src/components/Homepage/index.js b/src/components/Homepage/index.js index 0165787..f3102e6 100644 --- a/src/components/Homepage/index.js +++ b/src/components/Homepage/index.js @@ -48,6 +48,7 @@ class HomePageContainer extends React.Component { this.props.dispatch(startResetParentList()); } else if (pathname.includes("/search")) { + console.log("login check set search") this.setSearchItems(); return; @@ -90,6 +91,7 @@ class HomePageContainer extends React.Component { const idSplit = isGoogle ? history.location.pathname.split("/folder-google/") : isPersonal ? history.location.pathname.split("/folder-personal/") : history.location.pathname.split("/folder/"); const id = idSplit[1]; + this.props.dispatch(setSearch("")) this.props.dispatch(setCurrentRouteType("folder")) isGoogle ? this.props.dispatch(setIsGoogle()) : this.props.dispatch(setNotGoogle()) this.props.dispatch(setQuickFiles([])); @@ -120,6 +122,7 @@ class HomePageContainer extends React.Component { if (pathname === "/home") { + this.props.dispatch(setSearch("")) this.getFiles(); this.props.dispatch(startSetStorage()); this.props.dispatch(resetCurrentlySearching()); @@ -144,7 +147,7 @@ class HomePageContainer extends React.Component { this.props.dispatch(startSetFolders(undefined, undefined, value)); this.props.dispatch(setParent) this.props.dispatch(setParentList(["/"], ["Home"])) - this.props.dispatch(setSearch("")) + // this.props.dispatch(setSearch("")) this.props.dispatch(startSetStorage()); } @@ -199,7 +202,7 @@ class HomePageContainer extends React.Component { this.props.dispatch(startSetFileAndFolderItems("",parent, undefined, value, undefined, storageType, folderSearch)) this.props.dispatch(setCurrentlySearching()); parent ? this.props.dispatch(startSetParentList(parent)) : this.props.dispatch(setParentList(["/"], ["Home"])) - this.props.dispatch(setSearch("")) + this.props.dispatch(setSearch(value)) this.props.dispatch(startSetStorage()); this.props.dispatch(resetStorageSwitcherStorage()) this.props.dispatch(setQuickFiles([])) @@ -223,6 +226,7 @@ class HomePageContainer extends React.Component { } else if (this.lastLocationKey !== history.location.key) { + this.props.dispatch(setSearch("")) this.props.dispatch(setCurrentRouteType("home")) this.props.dispatch(setNotGoogle()); this.getFiles(this.clearCache); diff --git a/src/components/MainSection/MainSection.js b/src/components/MainSection/MainSection.js index 281dbf7..5582598 100644 --- a/src/components/MainSection/MainSection.js +++ b/src/components/MainSection/MainSection.js @@ -32,7 +32,7 @@ const MainSection = React.forwardRef((props, ref) => { {props.routeType === "search" ?
-

{props.files.length + props.folders.length} results for {props.cachedSearch}

+

{props.files.length + props.folders.length >= 50 ? "50+" : props.files.length + props.folders.length} results for {props.cachedSearch}

You are searching in {props.parent === "/" ? "Home" : props.parentNameList.length !== 0 ? props.parentNameList[props.parentNameList.length - 1] : "Unknown"} spacer Show results from everywhere

: undefined}