From 0f0971abb521ee6b5e30789ceb73fedfd315d055 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 28 Nov 2024 09:39:09 -0600 Subject: [PATCH] lodash -> es-toolkit --- package.json | 2 +- src/actions/compose.ts | 4 ++-- src/actions/preload.ts | 2 +- src/components/autosuggest-account-input.tsx | 4 ++-- src/components/hover-ref-wrapper.tsx | 2 +- src/components/hover-status-wrapper.tsx | 2 +- src/components/location-search.tsx | 4 ++-- src/components/scroll-top-button.tsx | 4 ++-- src/components/scrollable-list.tsx | 4 ++-- src/components/status-list.tsx | 4 ++-- src/components/ui/column.tsx | 2 +- src/components/ui/slider.tsx | 2 +- src/features/audio/index.tsx | 9 +++------ src/features/auth-login/components/registration-form.tsx | 4 ++-- src/features/bookmarks/index.tsx | 4 ++-- src/features/chats/components/chat-message.tsx | 2 +- src/features/compose/components/search-zap-split.tsx | 2 +- src/features/compose/components/search.tsx | 2 +- .../conversations/components/conversations-list.tsx | 4 ++-- src/features/domain-blocks/index.tsx | 4 ++-- src/features/event/event-discussion.tsx | 4 ++-- src/features/favourited-statuses/index.tsx | 4 ++-- src/features/follow-recommendations/index.tsx | 2 +- src/features/follow-requests/index.tsx | 4 ++-- src/features/followed-tags/index.tsx | 4 ++-- src/features/nostr/hooks/useNostrReq.ts | 2 +- src/features/notifications/components/setting-toggle.tsx | 2 +- src/features/notifications/index.tsx | 4 ++-- src/features/quotes/index.tsx | 4 ++-- src/features/scheduled-statuses/index.tsx | 4 ++-- src/features/status/index.tsx | 4 ++-- src/features/ui/components/image-loader.tsx | 2 +- src/features/ui/components/modals/media-modal.tsx | 4 ++-- .../steps/suggested-accounts-step.tsx | 2 +- src/features/ui/components/panels/account-note-panel.tsx | 2 +- src/features/ui/components/profile-dropdown.tsx | 2 +- src/features/ui/components/timeline.tsx | 2 +- src/features/video/index.tsx | 7 +++---- src/reducers/relationships.ts | 2 +- src/reducers/timelines.ts | 2 +- src/service-worker/sw.ts | 2 +- src/utils/errors.ts | 3 +-- src/utils/legacy.ts | 6 +++--- yarn.lock | 7 ++++++- 44 files changed, 74 insertions(+), 74 deletions(-) diff --git a/package.json b/package.json index 7637e47d9..144296929 100644 --- a/package.json +++ b/package.json @@ -100,6 +100,7 @@ "cssnano": "^6.0.0", "detect-passive-events": "^2.0.0", "emoji-mart": "^5.6.0", + "es-toolkit": "^1.27.0", "eslint-plugin-formatjs": "^5.2.2", "exifr": "^7.1.3", "graphemesplit": "^2.4.4", @@ -113,7 +114,6 @@ "leaflet": "^1.8.0", "lexical": "^0.18.0", "line-awesome": "^1.3.0", - "lodash": "^4.7.11", "mini-css-extract-plugin": "^2.6.0", "nostr-tools": "^2.3.0", "path-browserify": "^1.0.1", diff --git a/src/actions/compose.ts b/src/actions/compose.ts index 600cf869c..aa92dda7e 100644 --- a/src/actions/compose.ts +++ b/src/actions/compose.ts @@ -1,6 +1,6 @@ import axios, { Canceler } from 'axios'; +import { throttle } from 'es-toolkit'; import { List as ImmutableList } from 'immutable'; -import throttle from 'lodash/throttle'; import { defineMessages, IntlShape } from 'react-intl'; import api from 'soapbox/api/index.ts'; @@ -510,7 +510,7 @@ const fetchComposeSuggestionsAccounts = throttle((dispatch, getState, composeId, toast.showAlertForError(error); } }); -}, 200, { leading: true, trailing: true }); +}, 200, { edges: ['leading', 'trailing'] }); const fetchComposeSuggestionsEmojis = (dispatch: AppDispatch, composeId: string, token: string, customEmojis: CustomEmoji[]) => { const results = emojiSearch(token.replace(':', ''), { maxResults: 10 }, customEmojis); diff --git a/src/actions/preload.ts b/src/actions/preload.ts index f923b467f..7e16e3c40 100644 --- a/src/actions/preload.ts +++ b/src/actions/preload.ts @@ -1,4 +1,4 @@ -import mapValues from 'lodash/mapValues'; +import { mapValues } from 'es-toolkit'; import { verifyCredentials } from './auth.ts'; import { importFetchedAccounts } from './importer/index.ts'; diff --git a/src/components/autosuggest-account-input.tsx b/src/components/autosuggest-account-input.tsx index ecd3f8ae2..c64e92592 100644 --- a/src/components/autosuggest-account-input.tsx +++ b/src/components/autosuggest-account-input.tsx @@ -1,5 +1,5 @@ +import { throttle } from 'es-toolkit'; import { OrderedSet as ImmutableOrderedSet } from 'immutable'; -import throttle from 'lodash/throttle'; import { useState, useRef, useCallback, useEffect } from 'react'; import { accountSearch } from 'soapbox/actions/accounts.ts'; @@ -53,7 +53,7 @@ const AutosuggestAccountInput: React.FC = ({ setAccountIds(ImmutableOrderedSet(accountIds)); }) .catch(noOp); - }, 900, { leading: true, trailing: true }), [limit]); + }, 900, { edges: ['leading', 'trailing'] }), [limit]); const handleChange: React.ChangeEventHandler = e => { refreshCancelToken(); diff --git a/src/components/hover-ref-wrapper.tsx b/src/components/hover-ref-wrapper.tsx index e64210520..a6ce15308 100644 --- a/src/components/hover-ref-wrapper.tsx +++ b/src/components/hover-ref-wrapper.tsx @@ -1,5 +1,5 @@ import clsx from 'clsx'; -import debounce from 'lodash/debounce'; +import { debounce } from 'es-toolkit'; import { useRef } from 'react'; import { fetchAccount } from 'soapbox/actions/accounts.ts'; diff --git a/src/components/hover-status-wrapper.tsx b/src/components/hover-status-wrapper.tsx index 1f52cc942..d477f2034 100644 --- a/src/components/hover-status-wrapper.tsx +++ b/src/components/hover-status-wrapper.tsx @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce'; +import { debounce } from 'es-toolkit'; import { useRef } from 'react'; import { useDispatch } from 'react-redux'; diff --git a/src/components/location-search.tsx b/src/components/location-search.tsx index f8bab49c4..9867a52fb 100644 --- a/src/components/location-search.tsx +++ b/src/components/location-search.tsx @@ -1,8 +1,8 @@ import backspaceIcon from '@tabler/icons/outline/backspace.svg'; import searchIcon from '@tabler/icons/outline/search.svg'; import clsx from 'clsx'; +import { throttle } from 'es-toolkit'; import { OrderedSet as ImmutableOrderedSet } from 'immutable'; -import throttle from 'lodash/throttle'; import { useCallback, useEffect, useRef, useState } from 'react'; import { defineMessages, useIntl } from 'react-intl'; @@ -78,7 +78,7 @@ const LocationSearch: React.FC = ({ onSelected }) => { }) .catch(noOp); - }, 900, { leading: true, trailing: true }), []); + }, 900, { edges: ['leading', 'trailing'] }), []); useEffect(() => { if (value === '') { diff --git a/src/components/scroll-top-button.tsx b/src/components/scroll-top-button.tsx index 3bbaf4663..f12b34502 100644 --- a/src/components/scroll-top-button.tsx +++ b/src/components/scroll-top-button.tsx @@ -1,5 +1,5 @@ import arrowBarToUpIcon from '@tabler/icons/outline/arrow-bar-to-up.svg'; -import throttle from 'lodash/throttle'; +import { throttle } from 'es-toolkit'; import { useState, useEffect, useCallback } from 'react'; import { useIntl, MessageDescriptor } from 'react-intl'; @@ -57,7 +57,7 @@ const ScrollTopButton: React.FC = ({ setScrolled(scrollTop > threshold); setScrolledTop(scrollTop <= autoloadThreshold); - }, 150, { trailing: true }), [threshold, autoloadThreshold]); + }, 150, { edges: ['trailing'] }), [threshold, autoloadThreshold]); /** Scroll to top and trigger `onClick`. */ const handleClick: React.MouseEventHandler = useCallback(() => { diff --git a/src/components/scrollable-list.tsx b/src/components/scrollable-list.tsx index 2b0f2dcb8..334f00cdd 100644 --- a/src/components/scrollable-list.tsx +++ b/src/components/scrollable-list.tsx @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce'; +import { debounce } from 'es-toolkit'; import { useEffect, useRef, useMemo, useCallback, forwardRef } from 'react'; import { useHistory } from 'react-router-dom'; import { Virtuoso, Components, VirtuosoProps, VirtuosoHandle, ListRange, IndexLocationWithAlign } from 'react-virtuoso'; @@ -143,7 +143,7 @@ const ScrollableList = forwardRef(({ } else { topOffset.current = 0; } - }, 150, { trailing: true }), []); + }, 150, { edges: ['trailing'] }), []); useEffect(() => { document.addEventListener('scroll', handleScroll); diff --git a/src/components/status-list.tsx b/src/components/status-list.tsx index 5380d7611..9040bf1c6 100644 --- a/src/components/status-list.tsx +++ b/src/components/status-list.tsx @@ -1,5 +1,5 @@ import clsx from 'clsx'; -import debounce from 'lodash/debounce'; +import { debounce } from 'es-toolkit'; import { useRef, useCallback } from 'react'; import { FormattedMessage } from 'react-intl'; @@ -89,7 +89,7 @@ const StatusList: React.FC = ({ if (onLoadMore && maxId) { onLoadMore(maxId.replace('末suggestions-', '')); } - }, 300, { leading: true }), [onLoadMore, lastStatusId, statusIds.last()]); + }, 300, { edges: ['leading'] }), [onLoadMore, lastStatusId, statusIds.last()]); const selectChild = (index: number) => { node.current?.scrollIntoView({ diff --git a/src/components/ui/column.tsx b/src/components/ui/column.tsx index 92415faf8..07a8785be 100644 --- a/src/components/ui/column.tsx +++ b/src/components/ui/column.tsx @@ -1,5 +1,5 @@ import clsx from 'clsx'; -import throttle from 'lodash/throttle'; +import { throttle } from 'es-toolkit'; import { forwardRef, useCallback, useEffect, useState } from 'react'; import { useHistory } from 'react-router-dom'; diff --git a/src/components/ui/slider.tsx b/src/components/ui/slider.tsx index 8aed7ebcc..7782f3344 100644 --- a/src/components/ui/slider.tsx +++ b/src/components/ui/slider.tsx @@ -1,4 +1,4 @@ -import throttle from 'lodash/throttle'; +import { throttle } from 'es-toolkit'; import { useRef } from 'react'; type Point = { x: number; y: number }; diff --git a/src/features/audio/index.tsx b/src/features/audio/index.tsx index b195c3937..ca41c55cc 100644 --- a/src/features/audio/index.tsx +++ b/src/features/audio/index.tsx @@ -4,8 +4,7 @@ import playerPlayIcon from '@tabler/icons/outline/player-play.svg'; import volume3Icon from '@tabler/icons/outline/volume-3.svg'; import volumeIcon from '@tabler/icons/outline/volume.svg'; import clsx from 'clsx'; -import debounce from 'lodash/debounce'; -import throttle from 'lodash/throttle'; +import { debounce, throttle } from 'es-toolkit'; import { useEffect, useLayoutEffect, useRef, useState } from 'react'; import { defineMessages, useIntl } from 'react-intl'; @@ -126,9 +125,7 @@ const Audio: React.FC = (props) => { if (player.current) { _setDimensions(); } - }, 250, { - trailing: true, - }); + }, 250, { edges: ['trailing'] }); const handlePlay = () => { setPaused(false); @@ -263,7 +260,7 @@ const Audio: React.FC = (props) => { setPaused(true); } - }, 150, { trailing: true }); + }, 150, { edges: ['trailing'] }); const handleMouseEnter = () => { setHovered(true); diff --git a/src/features/auth-login/components/registration-form.tsx b/src/features/auth-login/components/registration-form.tsx index 3609dbe8f..63b0b4cf7 100644 --- a/src/features/auth-login/components/registration-form.tsx +++ b/src/features/auth-login/components/registration-form.tsx @@ -1,8 +1,8 @@ import atIcon from '@tabler/icons/outline/at.svg'; import checkIcon from '@tabler/icons/outline/check.svg'; import axios from 'axios'; +import { debounce } from 'es-toolkit'; import { Map as ImmutableMap } from 'immutable'; -import debounce from 'lodash/debounce'; import { useState, useRef, useCallback } from 'react'; import { useIntl, FormattedMessage, defineMessages } from 'react-intl'; import { Link, useHistory } from 'react-router-dom'; @@ -200,7 +200,7 @@ const RegistrationForm: React.FC = ({ inviteToken }) => { } }); - }, 1000, { trailing: true }), []); + }, 1000, { edges: ['trailing'] }), []); const onSubmit: React.FormEventHandler = () => { if (!passwordsMatch()) { diff --git a/src/features/bookmarks/index.tsx b/src/features/bookmarks/index.tsx index 3824eb609..444327f9b 100644 --- a/src/features/bookmarks/index.tsx +++ b/src/features/bookmarks/index.tsx @@ -1,5 +1,5 @@ +import { debounce } from 'es-toolkit'; import { OrderedSet as ImmutableOrderedSet } from 'immutable'; -import debounce from 'lodash/debounce'; import { useEffect } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; @@ -18,7 +18,7 @@ const messages = defineMessages({ const handleLoadMore = debounce((dispatch) => { dispatch(expandBookmarkedStatuses()); -}, 300, { leading: true }); +}, 300, { edges: ['leading'] }); interface IBookmarks { params?: { diff --git a/src/features/chats/components/chat-message.tsx b/src/features/chats/components/chat-message.tsx index bef3ecca2..22204041d 100644 --- a/src/features/chats/components/chat-message.tsx +++ b/src/features/chats/components/chat-message.tsx @@ -6,7 +6,7 @@ import moodSmileIcon from '@tabler/icons/outline/mood-smile.svg'; import trashIcon from '@tabler/icons/outline/trash.svg'; import { useMutation } from '@tanstack/react-query'; import clsx from 'clsx'; -import escape from 'lodash/escape'; +import { escape } from 'es-toolkit'; import { useMemo, useState } from 'react'; import { defineMessages, useIntl } from 'react-intl'; diff --git a/src/features/compose/components/search-zap-split.tsx b/src/features/compose/components/search-zap-split.tsx index b5a63e6fb..01c8ed2ca 100644 --- a/src/features/compose/components/search-zap-split.tsx +++ b/src/features/compose/components/search-zap-split.tsx @@ -1,6 +1,6 @@ import xIcon from '@tabler/icons/outline/x.svg'; import clsx from 'clsx'; -import debounce from 'lodash/debounce'; +import { debounce } from 'es-toolkit'; import { useCallback, useEffect } from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { useHistory } from 'react-router-dom'; diff --git a/src/features/compose/components/search.tsx b/src/features/compose/components/search.tsx index 775cc7178..81bf08392 100644 --- a/src/features/compose/components/search.tsx +++ b/src/features/compose/components/search.tsx @@ -1,7 +1,7 @@ import searchIcon from '@tabler/icons/outline/search.svg'; import xIcon from '@tabler/icons/outline/x.svg'; import clsx from 'clsx'; -import debounce from 'lodash/debounce'; +import { debounce } from 'es-toolkit'; import { useCallback, useEffect } from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { useHistory } from 'react-router-dom'; diff --git a/src/features/conversations/components/conversations-list.tsx b/src/features/conversations/components/conversations-list.tsx index 261ded52d..95b7371ce 100644 --- a/src/features/conversations/components/conversations-list.tsx +++ b/src/features/conversations/components/conversations-list.tsx @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce'; +import { debounce } from 'es-toolkit'; import { useRef } from 'react'; import { FormattedMessage } from 'react-intl'; @@ -48,7 +48,7 @@ const ConversationsList: React.FC = () => { const handleLoadOlder = debounce(() => { const maxId = conversations.getIn([-1, 'id']); if (maxId) dispatch(expandConversations({ maxId })); - }, 300, { leading: true }); + }, 300, { edges: ['leading'] }); return ( { dispatch(expandDomainBlocks()); -}, 300, { leading: true }); +}, 300, { edges: ['leading'] }); const DomainBlocks: React.FC = () => { const dispatch = useAppDispatch(); diff --git a/src/features/event/event-discussion.tsx b/src/features/event/event-discussion.tsx index 0e15e22c7..9de4eef4f 100644 --- a/src/features/event/event-discussion.tsx +++ b/src/features/event/event-discussion.tsx @@ -1,5 +1,5 @@ +import { debounce } from 'es-toolkit'; import { List as ImmutableList, OrderedSet as ImmutableOrderedSet } from 'immutable'; -import debounce from 'lodash/debounce'; import { useCallback, useEffect, useRef, useState } from 'react'; import { FormattedMessage } from 'react-intl'; @@ -154,7 +154,7 @@ const EventDiscussion: React.FC = (props) => { setNext(next); }).catch(() => {}); } - }, 300, { leading: true }), [next, status]); + }, 300, { edges: ['leading'] }), [next, status]); const hasDescendants = descendantsIds.size > 0; diff --git a/src/features/favourited-statuses/index.tsx b/src/features/favourited-statuses/index.tsx index ea79041d0..3c52a7f20 100644 --- a/src/features/favourited-statuses/index.tsx +++ b/src/features/favourited-statuses/index.tsx @@ -1,5 +1,5 @@ +import { debounce } from 'es-toolkit'; import { OrderedSet as ImmutableOrderedSet } from 'immutable'; -import debounce from 'lodash/debounce'; import { useCallback, useEffect } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; @@ -44,7 +44,7 @@ const Favourites: React.FC = ({ params }) => { } else if (account) { dispatch(expandAccountFavouritedStatuses(account.id)); } - }, 300, { leading: true }), [account?.id]); + }, 300, { edges: ['leading'] }), [account?.id]); useEffect(() => { if (isOwnAccount) diff --git a/src/features/follow-recommendations/index.tsx b/src/features/follow-recommendations/index.tsx index 4cf6865bf..20e1992b8 100644 --- a/src/features/follow-recommendations/index.tsx +++ b/src/features/follow-recommendations/index.tsx @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce'; +import { debounce } from 'es-toolkit'; import { useEffect } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; diff --git a/src/features/follow-requests/index.tsx b/src/features/follow-requests/index.tsx index 2f4b29498..28571692e 100644 --- a/src/features/follow-requests/index.tsx +++ b/src/features/follow-requests/index.tsx @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce'; +import { debounce } from 'es-toolkit'; import { useEffect } from 'react'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; @@ -17,7 +17,7 @@ const messages = defineMessages({ const handleLoadMore = debounce((dispatch) => { dispatch(expandFollowRequests()); -}, 300, { leading: true }); +}, 300, { edges: ['leading'] }); const FollowRequests: React.FC = () => { const dispatch = useAppDispatch(); diff --git a/src/features/followed-tags/index.tsx b/src/features/followed-tags/index.tsx index 5bd30fdda..a85789f0b 100644 --- a/src/features/followed-tags/index.tsx +++ b/src/features/followed-tags/index.tsx @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce'; +import { debounce } from 'es-toolkit'; import { useEffect } from 'react'; import { defineMessages, useIntl, FormattedMessage } from 'react-intl'; @@ -16,7 +16,7 @@ const messages = defineMessages({ const handleLoadMore = debounce((dispatch) => { dispatch(expandFollowedHashtags()); -}, 300, { leading: true }); +}, 300, { edges: ['leading'] }); const FollowedTags = () => { const intl = useIntl(); diff --git a/src/features/nostr/hooks/useNostrReq.ts b/src/features/nostr/hooks/useNostrReq.ts index aee482f59..8f27199d4 100644 --- a/src/features/nostr/hooks/useNostrReq.ts +++ b/src/features/nostr/hooks/useNostrReq.ts @@ -1,5 +1,5 @@ import { NSet, NostrEvent, NostrFilter } from '@nostrify/nostrify'; -import isEqual from 'lodash/isEqual'; +import { isEqual } from 'es-toolkit'; import { useEffect, useRef, useState } from 'react'; import { useNostr } from 'soapbox/contexts/nostr-context.tsx'; diff --git a/src/features/notifications/components/setting-toggle.tsx b/src/features/notifications/components/setting-toggle.tsx index 8dda40eb2..43581f193 100644 --- a/src/features/notifications/components/setting-toggle.tsx +++ b/src/features/notifications/components/setting-toggle.tsx @@ -1,4 +1,4 @@ -import get from 'lodash/get'; +import { get } from 'es-toolkit/compat'; import Toggle from 'soapbox/components/ui/toggle.tsx'; import { Settings } from 'soapbox/schemas/soapbox/settings.ts'; diff --git a/src/features/notifications/index.tsx b/src/features/notifications/index.tsx index f444d3507..d53e1cfbb 100644 --- a/src/features/notifications/index.tsx +++ b/src/features/notifications/index.tsx @@ -1,6 +1,6 @@ import clsx from 'clsx'; +import { debounce } from 'es-toolkit'; import { List as ImmutableList, Map as ImmutableMap } from 'immutable'; -import debounce from 'lodash/debounce'; import { useCallback, useEffect, useRef } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { createSelector } from 'reselect'; @@ -77,7 +77,7 @@ const Notifications = () => { const handleLoadOlder = useCallback(debounce(() => { const last = notifications.last(); dispatch(expandNotifications({ maxId: last && last.get('id') })); - }, 300, { leading: true }), [notifications]); + }, 300, { edges: ['leading'] }), [notifications]); const handleScrollToTop = useCallback(debounce(() => { dispatch(scrollTopNotifications(true)); diff --git a/src/features/quotes/index.tsx b/src/features/quotes/index.tsx index adf14fc59..ad4aec2d5 100644 --- a/src/features/quotes/index.tsx +++ b/src/features/quotes/index.tsx @@ -1,5 +1,5 @@ +import { debounce } from 'es-toolkit'; import { OrderedSet as ImmutableOrderedSet } from 'immutable'; -import debounce from 'lodash/debounce'; import { useEffect } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { useParams } from 'react-router-dom'; @@ -17,7 +17,7 @@ const messages = defineMessages({ }); const handleLoadMore = debounce((statusId: string, dispatch: React.Dispatch) => - dispatch(expandStatusQuotes(statusId)), 300, { leading: true }); + dispatch(expandStatusQuotes(statusId)), 300, { edges: ['leading'] }); const Quotes: React.FC = () => { const dispatch = useAppDispatch(); diff --git a/src/features/scheduled-statuses/index.tsx b/src/features/scheduled-statuses/index.tsx index 9c142c6fe..f687b0ec4 100644 --- a/src/features/scheduled-statuses/index.tsx +++ b/src/features/scheduled-statuses/index.tsx @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce'; +import { debounce } from 'es-toolkit'; import { useEffect } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; @@ -16,7 +16,7 @@ const messages = defineMessages({ const handleLoadMore = debounce((dispatch) => { dispatch(expandScheduledStatuses()); -}, 300, { leading: true }); +}, 300, { edges: ['leading'] }); const ScheduledStatuses = () => { const intl = useIntl(); diff --git a/src/features/status/index.tsx b/src/features/status/index.tsx index 3c7382192..8ca22eb27 100644 --- a/src/features/status/index.tsx +++ b/src/features/status/index.tsx @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce'; +import { debounce } from 'es-toolkit'; import { useCallback, useEffect, useState } from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { Redirect } from 'react-router-dom'; @@ -82,7 +82,7 @@ const StatusDetails: React.FC = (props) => { setNext(next); }).catch(() => { }); } - }, 300, { leading: true }), [next, status]); + }, 300, { edges: ['leading'] }), [next, status]); const handleRefresh = () => { return fetchData(); diff --git a/src/features/ui/components/image-loader.tsx b/src/features/ui/components/image-loader.tsx index 2635b106c..a22edc49e 100644 --- a/src/features/ui/components/image-loader.tsx +++ b/src/features/ui/components/image-loader.tsx @@ -141,7 +141,7 @@ class ImageLoader extends PureComponent {
{loading ? ( = (props) => { setNext(next); }).catch(() => { }); } - }, 300, { leading: true }), [next, status]); + }, 300, { edges: ['leading'] }), [next, status]); /** Fetch the status (and context) from the API. */ const fetchData = async () => { diff --git a/src/features/ui/components/modals/onboarding-flow-modal/steps/suggested-accounts-step.tsx b/src/features/ui/components/modals/onboarding-flow-modal/steps/suggested-accounts-step.tsx index 6fea85a05..c7f016912 100644 --- a/src/features/ui/components/modals/onboarding-flow-modal/steps/suggested-accounts-step.tsx +++ b/src/features/ui/components/modals/onboarding-flow-modal/steps/suggested-accounts-step.tsx @@ -1,5 +1,5 @@ import xIcon from '@tabler/icons/outline/x.svg'; -import debounce from 'lodash/debounce'; +import { debounce } from 'es-toolkit'; import { FormattedMessage } from 'react-intl'; import ScrollableList from 'soapbox/components/scrollable-list.tsx'; diff --git a/src/features/ui/components/panels/account-note-panel.tsx b/src/features/ui/components/panels/account-note-panel.tsx index f59fb528e..e391afd12 100644 --- a/src/features/ui/components/panels/account-note-panel.tsx +++ b/src/features/ui/components/panels/account-note-panel.tsx @@ -1,4 +1,4 @@ -import debounce from 'lodash/debounce'; +import { debounce } from 'es-toolkit'; import { useEffect, useRef, useState } from 'react'; import { FormattedMessage, defineMessages, useIntl } from 'react-intl'; diff --git a/src/features/ui/components/profile-dropdown.tsx b/src/features/ui/components/profile-dropdown.tsx index 2295cbdbc..2ab924313 100644 --- a/src/features/ui/components/profile-dropdown.tsx +++ b/src/features/ui/components/profile-dropdown.tsx @@ -2,7 +2,7 @@ import { useFloating } from '@floating-ui/react'; import logoutIcon from '@tabler/icons/outline/logout.svg'; import plusIcon from '@tabler/icons/outline/plus.svg'; import clsx from 'clsx'; -import throttle from 'lodash/throttle'; +import { throttle } from 'es-toolkit'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { Link } from 'react-router-dom'; diff --git a/src/features/ui/components/timeline.tsx b/src/features/ui/components/timeline.tsx index bb11f3985..07712bbff 100644 --- a/src/features/ui/components/timeline.tsx +++ b/src/features/ui/components/timeline.tsx @@ -1,5 +1,5 @@ +import { debounce } from 'es-toolkit'; import { OrderedSet as ImmutableOrderedSet } from 'immutable'; -import debounce from 'lodash/debounce'; import { useCallback } from 'react'; import { defineMessages } from 'react-intl'; diff --git a/src/features/video/index.tsx b/src/features/video/index.tsx index 92acc005a..c58ded688 100644 --- a/src/features/video/index.tsx +++ b/src/features/video/index.tsx @@ -5,8 +5,7 @@ import playerPlayIcon from '@tabler/icons/outline/player-play.svg'; import volume3Icon from '@tabler/icons/outline/volume-3.svg'; import volumeIcon from '@tabler/icons/outline/volume.svg'; import clsx from 'clsx'; -import debounce from 'lodash/debounce'; -import throttle from 'lodash/throttle'; +import { debounce, throttle } from 'es-toolkit'; import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'; import { defineMessages, useIntl } from 'react-intl'; @@ -376,7 +375,7 @@ const Video: React.FC = ({ const handleResize = useCallback(debounce(() => { setDimensions(); }, 250, { - trailing: true, + edges: ['trailing'], }), [player.current, cacheWidth]); const handleScroll = useCallback(throttle(() => { @@ -389,7 +388,7 @@ const Video: React.FC = ({ setPaused(true); video.current.pause(); } - }, 150, { trailing: true }), [video.current, paused]); + }, 150, { edges: ['trailing'] }), [video.current, paused]); const handleFullscreenChange = useCallback(() => { setFullscreen(isFullscreen()); diff --git a/src/reducers/relationships.ts b/src/reducers/relationships.ts index a5c322324..969a8a5a9 100644 --- a/src/reducers/relationships.ts +++ b/src/reducers/relationships.ts @@ -1,5 +1,5 @@ +import { get } from 'es-toolkit/compat'; import { Map as ImmutableMap } from 'immutable'; -import get from 'lodash/get'; import { type Relationship, relationshipSchema } from 'soapbox/schemas/index.ts'; diff --git a/src/reducers/timelines.ts b/src/reducers/timelines.ts index 19542c5a8..f583f05a1 100644 --- a/src/reducers/timelines.ts +++ b/src/reducers/timelines.ts @@ -1,3 +1,4 @@ +import { sample } from 'es-toolkit'; import { Map as ImmutableMap, List as ImmutableList, @@ -5,7 +6,6 @@ import { Record as ImmutableRecord, fromJS, } from 'immutable'; -import sample from 'lodash/sample'; import { ACCOUNT_BLOCK_SUCCESS, diff --git a/src/service-worker/sw.ts b/src/service-worker/sw.ts index 6323bd167..2688ff6c2 100644 --- a/src/service-worker/sw.ts +++ b/src/service-worker/sw.ts @@ -1,7 +1,7 @@ /// +import { unescape } from 'es-toolkit'; import IntlMessageFormat from 'intl-messageformat'; import 'intl-pluralrules'; -import unescape from 'lodash/unescape'; import expandIcon from '../assets/images/web-push/web-push-icon_expand.png'; import favouriteIcon from '../assets/images/web-push/web-push-icon_favourite.png'; diff --git a/src/utils/errors.ts b/src/utils/errors.ts index 78f8db8bd..dad0bf9ec 100644 --- a/src/utils/errors.ts +++ b/src/utils/errors.ts @@ -1,5 +1,4 @@ -import camelCase from 'lodash/camelCase'; -import startCase from 'lodash/startCase'; +import { camelCase, startCase } from 'es-toolkit'; const toSentence = (arr: string[]) => arr .reduce( diff --git a/src/utils/legacy.ts b/src/utils/legacy.ts index fb2bc06f4..18da65e0f 100644 --- a/src/utils/legacy.ts +++ b/src/utils/legacy.ts @@ -1,4 +1,4 @@ -import { default as lodashGet } from 'lodash/get'; +import { get as _get } from 'es-toolkit/compat'; interface LegacyMap { get(key: any): unknown; @@ -22,7 +22,7 @@ function immutableizeEntity>(entity: T): T & LegacyMa }, getIn(keyPath: any[]): unknown { - return lodashGet(entity, keyPath); + return _get(entity, keyPath); }, toJS() { @@ -41,7 +41,7 @@ function immutableizeStore>(state: S) }, getIn(keyPath: any[]): unknown { - return lodashGet(state, keyPath); + return _get(state, keyPath); }, find(predicate: (value: T & LegacyMap, key: string) => boolean): T & LegacyMap | undefined { diff --git a/yarn.lock b/yarn.lock index 54720fe9e..b8dd9ef34 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4325,6 +4325,11 @@ es-to-primitive@^1.2.1: is-date-object "^1.0.1" is-symbol "^1.0.2" +es-toolkit@^1.27.0: + version "1.27.0" + resolved "https://registry.yarnpkg.com/es-toolkit/-/es-toolkit-1.27.0.tgz#affc1aaf78d47e42d282c427c14bf8b610923f12" + integrity sha512-ETSFA+ZJArcuSCpzD2TjAy6UHpx4E4uqFsoDg9F/nTLogrLmVVZQ+zNxco5h7cWnA1nNak07IXsLcaSMih+ZPQ== + esbuild@^0.19.1: version "0.19.10" resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.19.10.tgz#55e83e4a6b702e3498b9f872d84bfb4ebcb6d16e" @@ -5989,7 +5994,7 @@ lodash.uniq@^4.5.0: resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= -lodash@^4.0.1, lodash@^4.17.15, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.7.11: +lodash@^4.0.1, lodash@^4.17.15, lodash@^4.17.20, lodash@^4.17.21: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==