From 60427cb3d7916171259037dd923fa219fa5df51c Mon Sep 17 00:00:00 2001 From: Anton Date: Thu, 14 Sep 2023 12:10:56 +0200 Subject: [PATCH] fixing hash tag issue --- dependency-graph.svg | 1169 +++++++++-------- .../Map/Subcomponents/ItemFormPopup.tsx | 4 +- .../ItemPopupComponents/TextView.tsx | 18 - src/Components/Map/hooks/useTags.tsx | 6 +- 4 files changed, 635 insertions(+), 562 deletions(-) diff --git a/dependency-graph.svg b/dependency-graph.svg index ae3f2780..b9071069 100644 --- a/dependency-graph.svg +++ b/dependency-graph.svg @@ -4,92 +4,92 @@ - - + + dependency-cruiser output - + cluster_src - -src + +src cluster_src/Components - -Components + +Components cluster_src/Components/AppShell - -AppShell + +AppShell cluster_src/Components/Auth - -Auth + +Auth cluster_src/Components/Gaming - -Gaming + +Gaming cluster_src/Components/Input - -Input + +Input cluster_src/Components/Map - -Map + +Map cluster_src/Components/Map/Subcomponents - -Subcomponents + +Subcomponents cluster_src/Components/Map/Subcomponents/ItemPopupComponents - -ItemPopupComponents + +ItemPopupComponents cluster_src/Components/Map/hooks - -hooks + +hooks cluster_src/Components/Profile - -Profile + +Profile cluster_src/Components/Templates - -Templates + +Templates cluster_src/Components/Typography - -Typography + +Typography cluster_src/SampleData - -SampleData + +SampleData cluster_src/Utils - -Utils + +Utils src/Components/AppShell/AppShell.tsx - -AppShell.tsx + +AppShell.tsx @@ -97,194 +97,200 @@ src/Components/AppShell/NavBar.tsx - -NavBar.tsx + +NavBar.tsx src/Components/AppShell/AppShell.tsx->src/Components/AppShell/NavBar.tsx - - + + src/Components/AppShell/DialogModal.tsx - -DialogModal.tsx + +DialogModal.tsx - + src/Components/AppShell/NavBar.tsx->src/Components/AppShell/DialogModal.tsx - - + + + + + +src/Components/Auth/index.tsx + + +index.tsx + + + + + +src/Components/AppShell/NavBar.tsx->src/Components/Auth/index.tsx + + src/Components/AppShell/Content.tsx - -Content.tsx + +Content.tsx - - -src/Components/AppShell/SideBar.tsx - - -SideBar.tsx - - - - - -src/Components/AppShell/SidebarSubmenu.tsx - - -SidebarSubmenu.tsx - - - - - -src/Components/AppShell/SideBar.tsx->src/Components/AppShell/SidebarSubmenu.tsx - - - - - -src/Components/AppShell/index.tsx - - -index.tsx - - - - - -src/Components/AppShell/index.tsx->src/Components/AppShell/AppShell.tsx - - - - - -src/Components/AppShell/index.tsx->src/Components/AppShell/Content.tsx - - - - - -src/Components/AppShell/index.tsx->src/Components/AppShell/SideBar.tsx - - - - -src/Components/Auth/LoginPage.tsx - - -LoginPage.tsx - - - - -src/Components/Input/TextInput.tsx - - -TextInput.tsx - - - - - -src/Components/Auth/LoginPage.tsx->src/Components/Input/TextInput.tsx - - - - - -src/Components/Typography/ErrorText.tsx - - -ErrorText.tsx - - - - - -src/Components/Auth/LoginPage.tsx->src/Components/Typography/ErrorText.tsx - - - - - -src/Components/Auth/SignupPage.tsx - - -SignupPage.tsx - - - - - -src/Components/Auth/SignupPage.tsx->src/Components/Input/TextInput.tsx - - - - - -src/Components/Auth/SignupPage.tsx->src/Components/Typography/ErrorText.tsx - - - - - -src/Components/Auth/index.tsx - - -index.tsx +src/Components/Auth/LoginPage.tsx + + +LoginPage.tsx - + src/Components/Auth/index.tsx->src/Components/Auth/LoginPage.tsx - - + + + + + +src/Components/Auth/SignupPage.tsx + + +SignupPage.tsx + + - + src/Components/Auth/index.tsx->src/Components/Auth/SignupPage.tsx - - + + src/Components/Auth/useAuth.tsx - -useAuth.tsx + +useAuth.tsx - + src/Components/Auth/index.tsx->src/Components/Auth/useAuth.tsx - - + + + + + +src/Components/AppShell/SideBar.tsx + + +SideBar.tsx + + + + + +src/Components/AppShell/SidebarSubmenu.tsx + + +SidebarSubmenu.tsx + + + + + +src/Components/AppShell/SideBar.tsx->src/Components/AppShell/SidebarSubmenu.tsx + + + + + +src/Components/AppShell/index.tsx + + +index.tsx + + + + + +src/Components/AppShell/index.tsx->src/Components/AppShell/AppShell.tsx + + + + + +src/Components/AppShell/index.tsx->src/Components/AppShell/Content.tsx + + + + + +src/Components/AppShell/index.tsx->src/Components/AppShell/SideBar.tsx + + + + + +src/Components/Input/TextInput.tsx + + +TextInput.tsx + + + + + +src/Components/Auth/LoginPage.tsx->src/Components/Input/TextInput.tsx + + + + + +src/Components/Typography/ErrorText.tsx + + +ErrorText.tsx + + + + + +src/Components/Auth/LoginPage.tsx->src/Components/Typography/ErrorText.tsx + + + + + +src/Components/Auth/SignupPage.tsx->src/Components/Input/TextInput.tsx + + + + + +src/Components/Auth/SignupPage.tsx->src/Components/Typography/ErrorText.tsx + + src/Components/Gaming/Modal.tsx - -Modal.tsx + +Modal.tsx @@ -292,8 +298,8 @@ src/Components/Gaming/Quests.tsx - -Quests.tsx + +Quests.tsx @@ -301,29 +307,29 @@ src/Components/Gaming/index.tsx - -index.tsx + +index.tsx - + src/Components/Gaming/index.tsx->src/Components/Gaming/Modal.tsx - - + + - + src/Components/Gaming/index.tsx->src/Components/Gaming/Quests.tsx - - + + src/Components/Input/TextAreaInput.tsx - -TextAreaInput.tsx + +TextAreaInput.tsx @@ -331,46 +337,59 @@ src/Components/Map/hooks/useTags.tsx - -useTags.tsx + +useTags.tsx - + src/Components/Input/TextAreaInput.tsx->src/Components/Map/hooks/useTags.tsx - - - - + + + + + +src/Utils/HashTagRegex.tsx + + +HashTagRegex.tsx + + + + + +src/Components/Map/hooks/useTags.tsx->src/Utils/HashTagRegex.tsx + + src/Components/Input/index.tsx - -index.tsx + +index.tsx - + src/Components/Input/index.tsx->src/Components/Input/TextInput.tsx - - + + - + src/Components/Input/index.tsx->src/Components/Input/TextAreaInput.tsx - - + + src/Components/Map/ItemForm.tsx - -ItemForm.tsx + +ItemForm.tsx @@ -378,8 +397,8 @@ src/Components/Map/ItemView.tsx - -ItemView.tsx + +ItemView.tsx @@ -387,685 +406,757 @@ src/Components/Map/Layer.tsx - -Layer.tsx + +Layer.tsx + + +src/Components/Map/Layer.tsx->src/Components/Map/hooks/useTags.tsx + + + src/Utils/MarkerIconFactory.ts - -MarkerIconFactory.ts + +MarkerIconFactory.ts - + src/Components/Map/Layer.tsx->src/Utils/MarkerIconFactory.ts - - + + src/Components/Map/hooks/useFilter.tsx - -useFilter.tsx + +useFilter.tsx - + src/Components/Map/Layer.tsx->src/Components/Map/hooks/useFilter.tsx - - + + src/Components/Map/hooks/useItems.tsx - -useItems.tsx + +useItems.tsx - + src/Components/Map/Layer.tsx->src/Components/Map/hooks/useItems.tsx - - + + + + + +src/Components/Map/hooks/useLeafletRefs.tsx + + +useLeafletRefs.tsx + + + + + +src/Components/Map/Layer.tsx->src/Components/Map/hooks/useLeafletRefs.tsx + + - + src/Components/Map/Subcomponents/ItemFormPopup.tsx - - -ItemFormPopup.tsx + + +ItemFormPopup.tsx - + src/Components/Map/Layer.tsx->src/Components/Map/Subcomponents/ItemFormPopup.tsx - - + + - + src/Components/Map/Subcomponents/ItemViewPopup.tsx - - -ItemViewPopup.tsx + + +ItemViewPopup.tsx - + src/Components/Map/Layer.tsx->src/Components/Map/Subcomponents/ItemViewPopup.tsx - - - - - -src/Components/Map/hooks/useItems.tsx->src/Components/Map/hooks/useTags.tsx - - + + - + src/Components/Map/hooks/useLayers.tsx - - -useLayers.tsx + + +useLayers.tsx - + src/Components/Map/hooks/useItems.tsx->src/Components/Map/hooks/useLayers.tsx - - - - - -src/Utils/HashTagRegex.tsx - - -HashTagRegex.tsx - - - - - -src/Components/Map/hooks/useItems.tsx->src/Utils/HashTagRegex.tsx - - + + - + src/Components/Map/Subcomponents/ItemFormPopup.tsx->src/Components/Input/TextInput.tsx - - + + - + src/Components/Map/Subcomponents/ItemFormPopup.tsx->src/Components/Input/TextAreaInput.tsx - - + + - + src/Components/Map/Subcomponents/ItemFormPopup.tsx->src/Components/Map/hooks/useTags.tsx - - + + - + src/Components/Map/Subcomponents/ItemFormPopup.tsx->src/Components/Map/hooks/useFilter.tsx - - + + - + src/Components/Map/Subcomponents/ItemFormPopup.tsx->src/Components/Map/hooks/useItems.tsx - - + + - + src/types.ts - - -types.ts + + +types.ts - + src/Components/Map/Subcomponents/ItemFormPopup.tsx->src/types.ts - - + + - + src/Components/Map/Subcomponents/ItemFormPopup.tsx->src/Utils/HashTagRegex.tsx - - + + - + src/Utils/RandomColor.ts - - -RandomColor.ts + + +RandomColor.ts - + src/Components/Map/Subcomponents/ItemFormPopup.tsx->src/Utils/RandomColor.ts - - + + - + src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx - - -HeaderView.tsx + + +HeaderView.tsx - + src/Components/Map/Subcomponents/ItemViewPopup.tsx->src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx - - + + - + src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx - - -TextView.tsx + + +TextView.tsx - + src/Components/Map/Subcomponents/ItemViewPopup.tsx->src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx - - + + - - -src/Components/Map/Subcomponents/AddButton.tsx - - -AddButton.tsx + + +src/Components/Map/Permissions.tsx + + +Permissions.tsx + + +src/Components/Map/Permissions.tsx->src/Components/Auth/index.tsx + + + + + +src/Components/Map/hooks/usePermissions.tsx + + +usePermissions.tsx + + + + + +src/Components/Map/Permissions.tsx->src/Components/Map/hooks/usePermissions.tsx + + + + + +src/Components/Map/hooks/usePermissions.tsx->src/Components/Auth/index.tsx + + + + + +src/Components/Map/Subcomponents/AddButton.tsx + + +AddButton.tsx + + + + + +src/Components/Map/Subcomponents/AddButton.tsx->src/Components/Map/hooks/usePermissions.tsx + + + - + src/Utils/DynamicHeroIcon.tsx - - -DynamicHeroIcon.tsx + + +DynamicHeroIcon.tsx - + src/Components/Map/Subcomponents/AddButton.tsx->src/Utils/DynamicHeroIcon.tsx - - + + - + src/Components/Map/Subcomponents/AddButton.tsx->src/Components/Map/hooks/useLayers.tsx - - + + - + src/Components/Map/Subcomponents/FilterControl.tsx - - -FilterControl.tsx + + +FilterControl.tsx - + src/Components/Map/Subcomponents/FilterControl.tsx->src/Components/Map/hooks/useFilter.tsx - - + + - + src/Components/Map/hooks/useWindowDimension.tsx - - -useWindowDimension.tsx + + +useWindowDimension.tsx - + src/Components/Map/Subcomponents/FilterControl.tsx->src/Components/Map/hooks/useWindowDimension.tsx - - + + - + src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx->src/Components/Map/hooks/useItems.tsx - - + + + + + +src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx->src/Components/Map/hooks/usePermissions.tsx + + - + src/Components/Map/Subcomponents/ItemPopupComponents/PopupStartEndInput.tsx - - -PopupStartEndInput.tsx + + +PopupStartEndInput.tsx - + src/Components/Map/Subcomponents/ItemPopupComponents/PopupStartEndInput.tsx->src/Components/Input/index.tsx - - + + - + src/Components/Map/Subcomponents/ItemPopupComponents/PopupTextAreaInput.tsx - - -PopupTextAreaInput.tsx + + +PopupTextAreaInput.tsx - + src/Components/Map/Subcomponents/ItemPopupComponents/PopupTextAreaInput.tsx->src/Components/Input/index.tsx - - + + - + src/Components/Map/Subcomponents/ItemPopupComponents/PopupTextInput.tsx - - -PopupTextInput.tsx + + +PopupTextInput.tsx - + src/Components/Map/Subcomponents/ItemPopupComponents/StartEndView.tsx - - -StartEndView.tsx + + +StartEndView.tsx - + src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx->src/Components/Map/hooks/useTags.tsx - - + + - + src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx->src/Components/Map/hooks/useFilter.tsx - - + + - + src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx->src/Utils/HashTagRegex.tsx - - + + - + src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx->src/Utils/RandomColor.ts - - + + - + src/Utils/ReplaceURLs.ts - - -ReplaceURLs.ts + + +ReplaceURLs.ts - + src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx->src/Utils/ReplaceURLs.ts - - + + - + src/Components/Map/Tags.tsx - - -Tags.tsx + + +Tags.tsx - + src/Components/Map/Tags.tsx->src/Components/Map/hooks/useTags.tsx - - + + - + src/Components/Map/UtopiaMap.css - - -UtopiaMap.css + + +UtopiaMap.css - + src/Components/Map/UtopiaMap.tsx - - -UtopiaMap.tsx + + +UtopiaMap.tsx - + src/Components/Map/UtopiaMap.tsx->src/Components/Map/hooks/useTags.tsx - - + + - + src/Components/Map/UtopiaMap.tsx->src/Components/Map/hooks/useFilter.tsx - - + + - + src/Components/Map/UtopiaMap.tsx->src/Components/Map/hooks/useItems.tsx - - + + + + + +src/Components/Map/UtopiaMap.tsx->src/Components/Map/hooks/useLeafletRefs.tsx + + + + + +src/Components/Map/UtopiaMap.tsx->src/Components/Map/hooks/usePermissions.tsx + + - + src/Components/Map/UtopiaMap.tsx->src/Components/Map/Subcomponents/AddButton.tsx - - + + - + src/Components/Map/UtopiaMap.tsx->src/Components/Map/hooks/useLayers.tsx - - + + - + src/Components/Map/UtopiaMap.tsx->src/Components/Map/Subcomponents/FilterControl.tsx - - + + - + src/Components/Map/UtopiaMap.tsx->src/Components/Map/UtopiaMap.css - - + + - + src/Components/Map/index.tsx - - -index.tsx + + +index.tsx - + src/Components/Map/index.tsx->src/Components/Map/ItemForm.tsx - - + + - + src/Components/Map/index.tsx->src/Components/Map/ItemView.tsx - - + + - + src/Components/Map/index.tsx->src/Components/Map/Layer.tsx - - + + + + + +src/Components/Map/index.tsx->src/Components/Map/Permissions.tsx + + - + src/Components/Map/index.tsx->src/Components/Map/Subcomponents/ItemPopupComponents/PopupStartEndInput.tsx - - + + - + src/Components/Map/index.tsx->src/Components/Map/Subcomponents/ItemPopupComponents/PopupTextAreaInput.tsx - - + + - + src/Components/Map/index.tsx->src/Components/Map/Subcomponents/ItemPopupComponents/StartEndView.tsx - - + + - + src/Components/Map/index.tsx->src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx - - + + - + src/Components/Map/index.tsx->src/Components/Map/Tags.tsx - - + + - + src/Components/Map/index.tsx->src/Components/Map/UtopiaMap.tsx - - + + - + src/Components/Profile/Settings.tsx - - -Settings.tsx + + +Settings.tsx + + +src/Components/Profile/Settings.tsx->src/Components/Auth/index.tsx + + + - + src/Components/Profile/Settings.tsx->src/Components/Input/TextInput.tsx - - + + - + src/Components/Profile/Settings.tsx->src/Components/Input/TextAreaInput.tsx - - + + - + src/Components/Templates/TitleCard.tsx - - -TitleCard.tsx + + +TitleCard.tsx - + src/Components/Profile/Settings.tsx->src/Components/Templates/TitleCard.tsx - - + + - + src/Components/Typography/Subtitle.tsx - - -Subtitle.tsx + + +Subtitle.tsx - + src/Components/Templates/TitleCard.tsx->src/Components/Typography/Subtitle.tsx - - + + - + src/Components/Profile/index.tsx - - -index.tsx + + +index.tsx - + src/Components/Profile/index.tsx->src/Components/Profile/Settings.tsx - - + + - + src/Components/Templates/CardPage.tsx - - -CardPage.tsx + + +CardPage.tsx - + src/Components/Templates/CardPage.tsx->src/Components/Templates/TitleCard.tsx - - + + - + src/Components/Templates/index.tsx - - -index.tsx + + +index.tsx - + src/Components/Templates/index.tsx->src/Components/Templates/TitleCard.tsx - - + + - + src/Components/Templates/index.tsx->src/Components/Templates/CardPage.tsx - - + + - + src/SampleData/data.js - - -data.js + + +data.js - + src/index.css - - -index.css + + +index.css - + src/index.tsx - - -index.tsx + + +index.tsx - - -src/index.tsx->src/Components/AppShell/index.tsx - - - - + src/index.tsx->src/Components/Auth/index.tsx - - + + + + + +src/index.tsx->src/Components/AppShell/index.tsx + + - + src/index.tsx->src/Components/Gaming/index.tsx - - + + - + src/index.tsx->src/Components/Input/index.tsx - - + + - + src/index.tsx->src/Components/Map/index.tsx - - + + - + src/index.tsx->src/Components/Profile/index.tsx - - + + - + src/index.tsx->src/Components/Templates/index.tsx - - + + - + src/index.tsx->src/index.css - - + + diff --git a/src/Components/Map/Subcomponents/ItemFormPopup.tsx b/src/Components/Map/Subcomponents/ItemFormPopup.tsx index fc295bee..a1318aab 100644 --- a/src/Components/Map/Subcomponents/ItemFormPopup.tsx +++ b/src/Components/Map/Subcomponents/ItemFormPopup.tsx @@ -49,8 +49,8 @@ export function ItemFormPopup(props: ItemFormPopupProps) { setSpinner(true); formItem.text.toLocaleLowerCase().match(hashTagRegex)?.map(tag=> { - if (!tags.find((t) => t.id === tag.slice(1))) { - addTag({id: tag.slice(1), color: randomColor()}) + if (!tags.find((t) => t.id.toLocaleLowerCase() === tag.slice(1).toLocaleLowerCase())) { + addTag({id: tag.slice(1).toLocaleLowerCase(), color: randomColor()}) } }); diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx index ba27c11d..831257f8 100644 --- a/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx @@ -12,29 +12,11 @@ import { useEffect, useRef } from 'react'; export const TextView = ({ item }: { item?: Item }) => { const tags = useTags(); const addTag = useAddTag(); - - const groupRef = useRef(null); - const addFilterTag = useAddFilterTag(); - const map = useMap(); - let replacedText; - // use init-Ref to prevent react18 from calling useEffect twice - const init = useRef(false) - useEffect(() => { - if (!init.current) { - item?.text.toLocaleLowerCase().match(hashTagRegex)?.map(tag=> { - if (!tags.find((t) => t.id === tag.slice(1))) { - addTag({id: tag.slice(1), color: randomColor()}) - } - }); - init.current = true; - } - }, []) - if (item && item.text) replacedText = fixUrls(item.text); diff --git a/src/Components/Map/hooks/useTags.tsx b/src/Components/Map/hooks/useTags.tsx index 7a631bbf..11ed16c3 100644 --- a/src/Components/Map/hooks/useTags.tsx +++ b/src/Components/Map/hooks/useTags.tsx @@ -30,11 +30,11 @@ function useTagsManager(initialTags: Tag[]): { switch (action.type) { case "ADD": const exist = state.find((tag) => - tag.id === action.tag.id ? true : false + tag.id.toLocaleLowerCase() === action.tag.id.toLocaleLowerCase() ? true : false ); if (!exist) return [ ...state, - {...action.tag, id: action.tag.id} + {...action.tag, id: action.tag.id.toLocaleLowerCase()} ]; else return state; @@ -71,7 +71,7 @@ function useTagsManager(initialTags: Tag[]): { tag, }); - if (!tags.some((t) => t.id === tag.id)) { + if (!tags.some((t) => t.id.toLocaleLowerCase() === tag.id.toLocaleLowerCase())) { api?.createItem && api.createItem(tag); } };