Skip to content
Snippets Groups Projects
Commit 04010663 authored by lfr20's avatar lfr20
Browse files

Fix upper search bar bug

parent e6218a8b
No related branches found
No related tags found
2 merge requests!57Merge of develop into master,!56Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...
......@@ -106,26 +106,16 @@ export default function Search(props) {
getRequest(url, handleSuccessfulGet, (error) => { console.log(error) })
};
(function(history){
const pushState = history.pushState;
history.pushState = function(state) {
if (typeof history.onpushstate == "function") {
history.onpushstate({state: state});
}
// Call your custom function here
return pushState.apply(history, arguments);
}
})(window.history);
useEffect(() => {
dispatch({
type: "HANDLE_SEARCH_BAR",
opened: false,
});
setIsLoading(true)
const urlParams = new URLSearchParams(window.location.search);
const query = urlParams.get("query");
const searchClass = urlParams.get("search_class");
console.log(query)
console.log(searchClass)
if (state.search.query !== query || state.search.class !== searchClass) {
dispatch({
type: "SAVE_SEARCH",
......@@ -136,12 +126,14 @@ export default function Search(props) {
});
}
collectStuff(searchClass)
return () =>
dispatch({
type: "HANDLE_SEARCH_BAR",
opened: false,
});
}, []);
}, [window.history.state.key])
useEffect(() => {
setIsLoading(true);
......@@ -171,6 +163,7 @@ export default function Search(props) {
<Dropdown options={options} value={optionResult}
onChange={(e) => {
setIsLoading(true);
console.log(window.history)
currOption = e.value;
setOption(currOption);
collectStuff(currOption, "");
......@@ -223,10 +216,10 @@ export default function Search(props) {
tags={card.tags}
rating={card.review_average}
id={card.id}
author={card.owner.name}
author={card.owner ? card.owner.name : ""}
description={card.description}
thumbnails={card.items_thumbnails}
avatar={card.owner.avatar}
avatar={card.owner ? card.owner.avatar : ""}
likeCount={card.likes_count}
followed={card.followed}
liked={card.liked}
......@@ -281,7 +274,7 @@ export default function Search(props) {
{resultsResource.map((card) => (
<Grid item xs={12} sm={6} md={4} lg={3} key={card.id}>
<ResourceCardFunction
avatar={card.publisher.avatar}
avatar={card.publisher ? card.publisher.avatar : ""}
id={card.id}
thumbnail={card.thumbnail}
type={card.object_type ? card.object_type : "Outros"}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment