diff --git a/app/soapbox/actions/accounts.ts b/app/soapbox/actions/accounts.ts index 14db17275..b4a54201f 100644 --- a/app/soapbox/actions/accounts.ts +++ b/app/soapbox/actions/accounts.ts @@ -10,10 +10,10 @@ import { } from './importer'; import type { AxiosError, CancelToken } from 'axios'; -import type { History } from 'history'; import type { Map as ImmutableMap } from 'immutable'; import type { AppDispatch, RootState } from 'soapbox/store'; import type { APIEntity, Status } from 'soapbox/types/entities'; +import type { History } from 'soapbox/types/history'; const ACCOUNT_CREATE_REQUEST = 'ACCOUNT_CREATE_REQUEST'; const ACCOUNT_CREATE_SUCCESS = 'ACCOUNT_CREATE_SUCCESS'; diff --git a/app/soapbox/actions/chats.ts b/app/soapbox/actions/chats.ts index 67b796408..f4ca85abe 100644 --- a/app/soapbox/actions/chats.ts +++ b/app/soapbox/actions/chats.ts @@ -6,8 +6,8 @@ import { getFeatures } from 'soapbox/utils/features'; import api, { getLinks } from '../api'; -import type { History } from 'history'; import type { AppDispatch, RootState } from 'soapbox/store'; +import type { History } from 'soapbox/types/history'; const CHATS_FETCH_REQUEST = 'CHATS_FETCH_REQUEST'; const CHATS_FETCH_SUCCESS = 'CHATS_FETCH_SUCCESS'; diff --git a/app/soapbox/actions/compose.ts b/app/soapbox/actions/compose.ts index 38efc838e..26768272f 100644 --- a/app/soapbox/actions/compose.ts +++ b/app/soapbox/actions/compose.ts @@ -19,11 +19,11 @@ import { openModal, closeModal } from './modals'; import { getSettings } from './settings'; import { createStatus } from './statuses'; -import type { History } from 'history'; import type { Emoji } from 'soapbox/components/autosuggest-emoji'; import type { AutoSuggestion } from 'soapbox/components/autosuggest-input'; import type { AppDispatch, RootState } from 'soapbox/store'; import type { Account, APIEntity, Status, Tag } from 'soapbox/types/entities'; +import type { History } from 'soapbox/types/history'; const { CancelToken, isCancel } = axios; diff --git a/app/soapbox/components/modal-root.tsx b/app/soapbox/components/modal-root.tsx index 388a5393b..33d8ee741 100644 --- a/app/soapbox/components/modal-root.tsx +++ b/app/soapbox/components/modal-root.tsx @@ -11,7 +11,6 @@ import { useAppDispatch, usePrevious } from 'soapbox/hooks'; import { queryClient } from 'soapbox/queries/client'; import { IPolicy, PolicyKeys } from 'soapbox/queries/policies'; -import type { UnregisterCallback } from 'history'; import type { ModalType } from 'soapbox/features/ui/components/modal-root'; import type { ReducerCompose } from 'soapbox/reducers/compose'; import type { ReducerRecord as ReducerComposeEvent } from 'soapbox/reducers/compose-event'; @@ -55,7 +54,7 @@ const ModalRoot: React.FC = ({ children, onCancel, onClose, type }) const ref = useRef(null); const activeElement = useRef(revealed ? document.activeElement as HTMLDivElement | null : null); const modalHistoryKey = useRef(); - const unlistenHistory = useRef(); + const unlistenHistory = useRef>(); const prevChildren = usePrevious(children); const prevType = usePrevious(type); diff --git a/app/soapbox/types/history.ts b/app/soapbox/types/history.ts new file mode 100644 index 000000000..9701614c0 --- /dev/null +++ b/app/soapbox/types/history.ts @@ -0,0 +1,9 @@ +import { useHistory, useLocation } from 'react-router-dom'; + +type History = ReturnType; +type Location = ReturnType; + +export type { + History, + Location, +}; \ No newline at end of file diff --git a/app/soapbox/utils/redirect.ts b/app/soapbox/utils/redirect.ts index f2b207660..84e22eb7c 100644 --- a/app/soapbox/utils/redirect.ts +++ b/app/soapbox/utils/redirect.ts @@ -1,9 +1,10 @@ -import { Location } from 'history'; import { useEffect } from 'react'; +import type { Location } from 'soapbox/types/history'; + const LOCAL_STORAGE_REDIRECT_KEY = 'soapbox:redirect-uri'; -const cacheCurrentUrl = (location: Location) => { +const cacheCurrentUrl = (location: Location) => { const actualUrl = encodeURIComponent(`${location.pathname}${location.search}`); localStorage.setItem(LOCAL_STORAGE_REDIRECT_KEY, actualUrl); return actualUrl; diff --git a/package.json b/package.json index 5d78c16e4..5617e69fa 100644 --- a/package.json +++ b/package.json @@ -122,7 +122,6 @@ "escape-html": "^1.0.3", "exif-js": "^2.3.0", "fork-ts-checker-webpack-plugin": "^7.2.11", - "history": "^4.10.1", "html-webpack-harddisk-plugin": "^2.0.0", "html-webpack-plugin": "^5.5.0", "http-link-header": "^1.0.2", diff --git a/yarn.lock b/yarn.lock index 8a374b2da..055e13356 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6287,7 +6287,7 @@ he@^1.2.0: resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f" integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw== -history@^4.10.1, history@^4.9.0: +history@^4.9.0: version "4.10.1" resolved "https://registry.yarnpkg.com/history/-/history-4.10.1.tgz#33371a65e3a83b267434e2b3f3b1b4c58aad4cf3" integrity sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==