mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
changed tag url seperator to semikolon to avoid conflicts with tags that contain commas
This commit is contained in:
parent
e3a1b4dc54
commit
e229b272ca
@ -24,10 +24,12 @@ const filterTags = useFilterTags()
|
||||
|
||||
useEffect(() => {
|
||||
let params = new URLSearchParams(location.search);
|
||||
let urlTags = params.get("tags")?.split(",");
|
||||
if(urlTags?.some(ut => !filterTags.find(ft => ut.toLocaleLowerCase() === ft.name.toLocaleLowerCase()))||filterTags?.some(ft => !urlTags?.find(ut => ut.toLocaleLowerCase() === ft.name.toLocaleLowerCase())))
|
||||
let urlTags = params.get("tags")
|
||||
let decodedTags = urlTags ? decodeURIComponent(urlTags) : "";
|
||||
let decodedTagsArray = decodedTags.split(";");
|
||||
if(decodedTagsArray?.some(ut => !filterTags.find(ft => ut.toLocaleLowerCase() === ft.name.toLocaleLowerCase()))||filterTags?.some(ft => !decodedTagsArray?.find(ut => ut.toLocaleLowerCase() === ft.name.toLocaleLowerCase())))
|
||||
{resetFilterTags()
|
||||
urlTags?.map(urlTag => {
|
||||
decodedTagsArray?.map(urlTag => {
|
||||
const tag = tags.find(t => t.name.toLocaleLowerCase() === urlTag.toLocaleLowerCase())
|
||||
tag && addFilterTag(tag)
|
||||
});}
|
||||
|
||||
@ -127,12 +127,13 @@ function useFilterManager(initialTags: Tag[]): {
|
||||
|
||||
const [searchPhrase, searchPhraseSet] = React.useState<string>("");
|
||||
|
||||
const addFilterTag = (tag: Tag) => {
|
||||
const addFilterTag = useCallback((tag: Tag) => {
|
||||
let params = new URLSearchParams(location.search);
|
||||
let urlTags = params.get("tags")
|
||||
let decodedTags = urlTags ? decodeURIComponent(urlTags) : "";
|
||||
|
||||
let params = new URLSearchParams(window.location.search);
|
||||
let urlTags = params.get("tags");
|
||||
if(!urlTags?.includes(tag.name))
|
||||
params.set("tags", `${urlTags ? urlTags : ""}${urlTags? ',' : ''}${tag.name}`)
|
||||
if(!decodedTags?.includes(tag.name))
|
||||
params.set("tags", `${urlTags ? urlTags : ""}${urlTags? ';' : ''}${tag.name}`)
|
||||
if(windowDimensions.width < 786 && location.pathname.split("/").length > 2) navigate("/" + `${params ? `?${params}` : ""}`);
|
||||
else navigate(location.pathname + `${params ? `?${params}` : ""}`);
|
||||
|
||||
@ -144,14 +145,14 @@ function useFilterManager(initialTags: Tag[]): {
|
||||
tag,
|
||||
});
|
||||
|
||||
};
|
||||
}, []);
|
||||
|
||||
const removeFilterTag = useCallback((name: string) => {
|
||||
|
||||
let params = new URLSearchParams(window.location.search);
|
||||
let urlTags = params.get("tags");
|
||||
let newUrlTags = "";
|
||||
let tags = urlTags?.split(",");
|
||||
let tags = urlTags?.split(";");
|
||||
if(tags?.length==0 && urlTags?.length && urlTags?.length > 0) tags[0]=urlTags;
|
||||
tags?.map(urlTag => {
|
||||
if(!(urlTag.toLocaleLowerCase() === name.toLocaleLowerCase()))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user