Refactor: Use UrlHelper utilities in more components

Co-authored-by: antontranelis <31516529+antontranelis@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-11-13 15:43:04 +00:00
parent 683d12b99f
commit 9092241461
3 changed files with 6 additions and 10 deletions

View File

@ -5,7 +5,6 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
/* eslint-disable @typescript-eslint/prefer-optional-chain */
/* eslint-disable @typescript-eslint/restrict-template-expressions */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import { LatLng } from 'leaflet'
import { forwardRef, useState } from 'react'
@ -17,6 +16,7 @@ import { useRemoveItem, useUpdateItem } from '#components/Map/hooks/useItems'
import { usePopupForm } from '#components/Map/hooks/usePopupForm'
import { useSetSelectPosition } from '#components/Map/hooks/useSelectPosition'
import { timeAgo } from '#utils/TimeAgo'
import { removeItemFromUrl } from '#utils/UrlHelper'
import { HeaderView } from './ItemPopupComponents/HeaderView'
import { TextView } from './ItemPopupComponents/TextView'
@ -80,8 +80,7 @@ export const ItemViewPopup = forwardRef((props: ItemViewPopupProps, ref: any) =>
}
setLoading(false)
map.closePopup()
const params = new URLSearchParams(window.location.search)
window.history.pushState({}, '', '/' + `${params ? `?${params}` : ''}`)
removeItemFromUrl()
navigate('/')
}

View File

@ -17,6 +17,7 @@ import { ActionButton } from '#components/Profile/Subcomponents/ActionsButton'
import { LinkedItemsHeaderView } from '#components/Profile/Subcomponents/LinkedItemsHeaderView'
import { TagView } from '#components/Templates/TagView'
import { timeAgo } from '#utils/TimeAgo'
import { setUrlParam } from '#utils/UrlHelper'
import type { Item } from '#types/Item'
import type { Tag } from '#types/Tag'
@ -67,11 +68,7 @@ export const TabsView = ({
const updateActiveTab = useCallback(
(id: number) => {
setActiveTab(id)
const params = new URLSearchParams(window.location.search)
params.set('tab', `${id}`)
const newUrl = location.pathname + '?' + params.toString()
window.history.pushState({}, '', newUrl)
setUrlParam('tab', `${id}`)
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[location.pathname],

View File

@ -14,6 +14,7 @@ import { toast } from 'react-toastify'
import { encodeTag } from '#utils/FormatTags'
import { hashTagRegex } from '#utils/HashTagRegex'
import { randomColor } from '#utils/RandomColor'
import { removeItemFromUrl } from '#utils/UrlHelper'
import type { FormState } from '#types/FormState'
import type { Item } from '#types/Item'
@ -185,8 +186,7 @@ export const handleDelete = async (
toast.success('Item deleted')
map.closePopup()
const params = new URLSearchParams(window.location.search)
window.history.pushState({}, '', '/' + `${params ? `?${params}` : ''}`)
removeItemFromUrl()
navigate('/')
} catch (error) {
toast.error(error instanceof Error ? error.message : String(error))