Skip to content

Commit

Permalink
refactor: use != instead of !==
Browse files Browse the repository at this point in the history
  • Loading branch information
clintonlunn committed Nov 25, 2024
1 parent 591154e commit 47e4bd2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/app/(maps)/components/FullScreenMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ export const FullScreenMap: React.FC = () => {

const { camera, areaId: urlAreaId } = urlParams.fromUrl()

if (urlAreaId !== null) {
if (urlAreaId != null) {
setAreaId(urlAreaId)
}

// If camera params exist in URL, use them
if (camera !== null) {
if (camera != null) {
setCenter([camera.center.lng, camera.center.lat])
setZoom(camera.zoom)
setIsInitialized(true)
Expand Down
12 changes: 6 additions & 6 deletions src/js/hooks/useUrlParams.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ const useUrlParams = (): UseUrlParamsReturn => {
const toUrl = ({ camera, areaId }: UrlProps): string => {
const params = new URLSearchParams()

if (areaId !== null && areaId !== undefined) {
if (areaId != null) {
params.set('areaId', areaId)
}

const baseUrl = `${pathname}?`
const cameraParam = (camera !== null && camera !== undefined) ? `camera=${cameraInfoToQuery(camera)}` : ''
const cameraParam = (camera != null) ? `camera=${cameraInfoToQuery(camera)}` : ''
const otherParams = params.toString()

if (cameraParam !== null && otherParams !== null) {
if (cameraParam != null && otherParams != null) {
return `${baseUrl}${cameraParam}&${otherParams}`
} else if (cameraParam !== null) {
} else if (cameraParam != null) {
return `${baseUrl}${cameraParam}`
} else if (otherParams !== null) {
} else if (otherParams != null) {
return `${baseUrl}${otherParams}`
}

Expand All @@ -37,7 +37,7 @@ const useUrlParams = (): UseUrlParamsReturn => {
const fromUrl = (): UrlProps => {
const cameraParam = searchParams.get('camera')
return {
camera: cameraParam !== null ? queryToCameraInfo(cameraParam) : null,
camera: cameraParam != null ? queryToCameraInfo(cameraParam) : null,
areaId: searchParams.get('areaId')
}
}
Expand Down

0 comments on commit 47e4bd2

Please sign in to comment.