From 1cccabc6bb18455cb15cafb9207093248f21dbe4 Mon Sep 17 00:00:00 2001 From: Dylan Audius Date: Thu, 12 Nov 2026 09:47:38 -0800 Subject: [PATCH] chore: remove dead code, @ts-ignores and stale terminology Low-risk part of #14665: unused files and exports, @ts-ignore replaced with types, discovery/content node comments renamed to validator node, shared mobile skip/restart constants, web hooks README. Co-Authored-By: Claude Opus 5.5 --- packages/common/src/adapters/activity.ts | 20 -- packages/common/src/adapters/coin.ts | 43 ----- packages/common/src/adapters/notification.ts | 12 +- packages/common/src/adapters/search.ts | 12 -- packages/common/src/api/index.ts | 1 - .../src/api/tan-query/coins/useCoinPair.ts | 7 - .../collection/useUpdateCollection.ts | 174 ------------------ .../src/api/tan-query/comments/useComments.ts | 6 +- .../tan-query/events/useAllRemixContests.ts | 4 +- .../src/api/tan-query/jupiter/solanaUtils.ts | 88 +-------- .../api/tan-query/lineups/usePremiumTracks.ts | 96 ---------- .../playlist-updates/usePlaylistUpdates.ts | 8 - .../purchases/useUSDCTransactions.ts | 11 +- .../src/api/tan-query/reactions/utils.ts | 18 -- .../tan-query/saga-utils/queryCollection.ts | 19 -- .../api/tan-query/saga-utils/queryTrack.ts | 8 +- .../src/api/tan-query/saga-utils/queryUser.ts | 17 -- .../src/api/tan-query/tracks/useTracks.ts | 21 --- .../api/tan-query/users/useUnfollowUser.ts | 120 ------------ .../api/tan-query/users/useUpdateProfile.ts | 2 +- .../src/api/tan-query/users/useUpdateUser.ts | 4 - .../common/src/api/tan-query/users/useUser.ts | 8 - .../api/tan-query/wallets/useAudioBalance.ts | 86 --------- packages/common/src/hooks/useInstanceVar.ts | 3 +- packages/common/src/models/Activity.ts | 16 -- packages/common/src/models/Status.ts | 16 -- packages/common/src/models/Track.ts | 5 - .../services/audius-backend/AudiusBackend.ts | 2 +- .../src/services/oauth/formatSocialProfile.ts | 63 +------ .../src/services/remote-config/types.ts | 4 +- packages/common/src/store/account/sagas.ts | 2 +- .../store/pages/audio-rewards/selectors.ts | 1 - packages/common/src/store/sagas.ts | 57 ------ packages/common/src/utils/challenges.ts | 11 -- .../common/src/utils/commonPasswordCheck.ts | 6 +- packages/common/src/utils/contentTypeUtils.ts | 5 - .../common/src/utils/formatTrackTimestamp.ts | 0 packages/common/src/utils/formatUtil.ts | 14 -- packages/common/src/utils/reducer.ts | 9 - packages/common/src/utils/sagaHelpers.ts | 80 +------- packages/common/src/utils/selectorHelpers.ts | 17 -- packages/common/src/utils/socialLinks.ts | 7 - packages/common/src/utils/stringUtils.ts | 39 ---- packages/common/src/utils/uid.ts | 39 ---- packages/common/src/utils/urlUtils.ts | 2 - .../FilterButton/FilterButtonKeyHandler.tsx | 102 ---------- .../button/FollowButton/FollowButton.tsx | 2 - .../src/components/modal/findAncestor.ts | 14 +- .../src/components/audio/AudioPlayer.tsx | 4 +- .../mobile/src/components/audio/constants.ts | 8 + .../components/comments/CommentActionBar.tsx | 2 +- .../components/contest-card/ContestCard.tsx | 2 +- .../now-playing-drawer/NowPlayingDrawer.tsx | 6 +- packages/mobile/src/haptics.ts | 2 - packages/mobile/src/notifications.ts | 2 +- .../src/screens/app-screen/AppTabScreen.tsx | 5 +- .../edit-track-screen/EditTrackForm.tsx | 1 - .../components/SolanaPhoneOption.tsx | 1 - .../src/screens/form-screen/FormScreen.tsx | 1 - .../ProfileHeader/ProfileSocials.tsx | 1 - .../screens/settings-screen/SettingsRow.tsx | 1 - .../createPlaylistRequestedSaga.ts | 1 - packages/mobile/src/store/chat/sagas.ts | 1 - packages/mobile/src/utils/theme.ts | 2 - packages/sdk/src/sdk/api/challenges/types.ts | 1 - .../src/sdk/services/AntiAbuseOracle/types.ts | 13 +- .../EntityManager/EntityManagerClient.ts | 5 +- .../src/sdk/services/Solana/SolanaRelay.ts | 10 +- .../Solana/SolanaRelayWalletAdapter.ts | 6 +- .../RewardManagerClient.ts | 2 +- .../sdk/src/sdk/services/Storage/Storage.ts | 8 +- .../StorageNodeSelector.ts | 2 +- .../StorageNodeSelector/getNStorageNodes.ts | 96 ---------- .../StorageNodeSelector/isNodeHealthy.ts | 34 ++++ packages/sdk/src/sdk/utils/deepPartial.ts | 10 - packages/sdk/src/sdk/utils/localStorage.ts | 19 -- packages/sdk/src/sdk/utils/object.ts | 9 - packages/sdk/src/sdk/utils/uuid.ts | 20 -- .../src/common/store/pages/signon/sagas.ts | 2 +- packages/web/src/hooks/README.md | 18 +- packages/web/src/hooks/useScript.ts | 25 --- packages/web/src/pages/dev-tools/messages.ts | 2 +- 82 files changed, 104 insertions(+), 1519 deletions(-) delete mode 100644 packages/common/src/api/tan-query/collection/useUpdateCollection.ts delete mode 100644 packages/common/src/api/tan-query/lineups/usePremiumTracks.ts delete mode 100644 packages/common/src/api/tan-query/reactions/utils.ts delete mode 100644 packages/common/src/api/tan-query/users/useUnfollowUser.ts delete mode 100644 packages/common/src/models/Activity.ts delete mode 100644 packages/common/src/utils/formatTrackTimestamp.ts delete mode 100644 packages/harmony/src/components/button/FilterButton/FilterButtonKeyHandler.tsx create mode 100644 packages/mobile/src/components/audio/constants.ts delete mode 100644 packages/sdk/src/sdk/services/StorageNodeSelector/getNStorageNodes.ts create mode 100644 packages/sdk/src/sdk/services/StorageNodeSelector/isNodeHealthy.ts delete mode 100644 packages/sdk/src/sdk/utils/deepPartial.ts delete mode 100644 packages/sdk/src/sdk/utils/localStorage.ts delete mode 100644 packages/sdk/src/sdk/utils/object.ts delete mode 100644 packages/sdk/src/sdk/utils/uuid.ts delete mode 100644 packages/web/src/hooks/useScript.ts diff --git a/packages/common/src/adapters/activity.ts b/packages/common/src/adapters/activity.ts index a31cce83a10..bd36465bb08 100644 --- a/packages/common/src/adapters/activity.ts +++ b/packages/common/src/adapters/activity.ts @@ -36,26 +36,6 @@ function normalizeActivityItem( ) } -export const activityFromSDK = (input: Activity) => { - const { timestamp, itemType: item_type, item } = input - if (item_type === ActivityItemTypeEnum.Track) { - const normalized = normalizeActivityItem(item as object, item_type) - return { - timestamp, - item_type, - item: userTrackMetadataFromSDK(normalized as Track) - } - } else if (item_type === ActivityItemTypeEnum.Playlist) { - const normalized = normalizeActivityItem(item as object, item_type) - return { - timestamp, - item_type, - item: userCollectionMetadataFromSDK(normalized as Playlist) - } - } - return undefined -} - export const trackActivityFromSDK = (input: Activity) => { const { timestamp, itemType: item_type, item } = input if (item_type === ActivityItemTypeEnum.Track) { diff --git a/packages/common/src/adapters/coin.ts b/packages/common/src/adapters/coin.ts index ed3ce87991d..27b20effe48 100644 --- a/packages/common/src/adapters/coin.ts +++ b/packages/common/src/adapters/coin.ts @@ -90,12 +90,6 @@ export const coinFromSdk = (input: CoinSDK | undefined): Coin | undefined => { } } -/** - * Converts a list of SDK `Coin` responses to CoinMetadata list - */ -export const coinMetadataListFromSDK = (input?: CoinSDK[]): CoinMetadata[] => - input ? input.map(coinMetadataFromCoin).filter(removeNullable) : [] - /** * Converts a SDK `UserCoin` response to UserCoin, parsing ownerId from HashId string to number */ @@ -123,40 +117,3 @@ export const coinListFromSDK = (input?: CoinSDK[]): Coin[] => */ export const userCoinListFromSDK = (input?: UserCoinSdk[]): UserCoin[] => input ? input.map(userCoinFromSdk).filter(removeNullable) : [] - -/** - * Creates a map of coins keyed by ticker symbol - */ -export const coinMapFromSDK = ( - input?: CoinSDK[] -): Record => { - const coinMap: Record = {} - - if (input) { - input.forEach((coin) => { - const coinMetadata = coinMetadataFromCoin(coin) - if (coinMetadata.ticker) { - coinMap[coinMetadata.ticker] = coinMetadata - } - }) - } - - return coinMap -} - -/** - * Gets all token symbols from a list of coins - */ -export const getTokenSymbolsFromCoins = (coins: CoinMetadata[]): string[] => - coins.map((coin) => coin.ticker || '').filter(Boolean) - -/** - * Gets token mints by symbol from a list of coins - */ -export const getTokenMintsBySymbolsFromCoins = ( - coins: CoinMetadata[], - symbols: string[] -): string[] => - coins - .filter((coin) => coin.ticker && symbols.includes(coin.ticker)) - .map((coin) => coin.mint) diff --git a/packages/common/src/adapters/notification.ts b/packages/common/src/adapters/notification.ts index bf188d90f53..61bcc109415 100644 --- a/packages/common/src/adapters/notification.ts +++ b/packages/common/src/adapters/notification.ts @@ -494,8 +494,7 @@ export const notificationFromSDK = ( const data = action.data entityId = HashId.parse(data.entityId) commentId = OptionalHashId.parse(data.commentId) - // @ts-ignore - entityType = data.type + entityType = data.type as Entity return HashId.parse(data.commentUserId) }) .filter(removeNullable) @@ -523,8 +522,7 @@ export const notificationFromSDK = ( entityId = HashId.parse(data.entityId) entityUserId = HashId.parse(data.entityUserId) commentId = OptionalHashId.parse(data.commentId) - // @ts-ignore - entityType = data.type + entityType = data.type as Entity return HashId.parse(data.commentUserId) }) .filter(removeNullable) @@ -551,8 +549,7 @@ export const notificationFromSDK = ( entityId = HashId.parse(data.entityId) entityUserId = HashId.parse(data.entityUserId) commentId = OptionalHashId.parse(data.commentId) - // @ts-ignore - entityType = data.type + entityType = data.type as Entity return HashId.parse(data.commentUserId) }) .filter(removeNullable) @@ -577,8 +574,7 @@ export const notificationFromSDK = ( entityId = HashId.parse(data.entityId) entityUserId = HashId.parse(data.entityUserId) commentId = OptionalHashId.parse(data.commentId) - // @ts-ignore - entityType = data.type + entityType = data.type as Entity return HashId.parse(data.reacterUserId) }) .filter(removeNullable) diff --git a/packages/common/src/adapters/search.ts b/packages/common/src/adapters/search.ts index 6b79db45996..a3d22c11ae4 100644 --- a/packages/common/src/adapters/search.ts +++ b/packages/common/src/adapters/search.ts @@ -95,15 +95,3 @@ export const searchResultsFromSDK = ( saved_albums } } - -export const AUTOCOMPLETE_TOTAL_RESULTS = 3 - -export const limitAutocompleteResults = ( - results: SearchResults, - maxResults: number = AUTOCOMPLETE_TOTAL_RESULTS -): SearchResults => { - return Object.keys(results).reduce((acc, key) => { - acc[key] = results[key].slice(0, Math.min(maxResults, results[key].length)) - return acc - }, {} as SearchResults) -} diff --git a/packages/common/src/api/index.ts b/packages/common/src/api/index.ts index e59c3d4bb13..0a5068b3dae 100644 --- a/packages/common/src/api/index.ts +++ b/packages/common/src/api/index.ts @@ -75,7 +75,6 @@ export * from './tan-query/purchases/useSalesAggregate' // Reactions export * from './tan-query/reactions/types' -export * from './tan-query/reactions/utils' // Remixes export * from './tan-query/remixes/useRemixesLineup' diff --git a/packages/common/src/api/tan-query/coins/useCoinPair.ts b/packages/common/src/api/tan-query/coins/useCoinPair.ts index b026d4bc42e..9b3e6e5b47e 100644 --- a/packages/common/src/api/tan-query/coins/useCoinPair.ts +++ b/packages/common/src/api/tan-query/coins/useCoinPair.ts @@ -101,10 +101,3 @@ export const useCoinPair = ( data: queryResult.data || createFallbackPair() } } - -// Hook for getting default AUDIO/USDC pair -export const useDefaultTokenPair = ( - options?: Partial> -) => { - return useCoinPair({ baseSymbol: 'AUDIO', quoteSymbol: 'USDC' }, options) -} diff --git a/packages/common/src/api/tan-query/collection/useUpdateCollection.ts b/packages/common/src/api/tan-query/collection/useUpdateCollection.ts deleted file mode 100644 index 6c89db25c22..00000000000 --- a/packages/common/src/api/tan-query/collection/useUpdateCollection.ts +++ /dev/null @@ -1,174 +0,0 @@ -import { Id } from '@audius/sdk' -import { useMutation, useQueryClient } from '@tanstack/react-query' -import { isEqual } from 'lodash' -import { useDispatch } from 'react-redux' - -import { playlistMetadataForUpdateWithSDK } from '~/adapters/collection' -import { fileToSdk } from '~/adapters/track' -import { - getCollectionQueryKey, - getTrackQueryKey, - useCurrentUserId -} from '~/api' -import { useQueryContext } from '~/api/tan-query/utils' -import { isContentUSDCPurchaseGated } from '~/models' -import { Collection } from '~/models/Collection' -import { ID } from '~/models/Identifiers' -import { renameAccountPlaylist } from '~/store/account/slice' -import { EditCollectionValues } from '~/store/cache/collections/types' -import { removeNullable } from '~/utils' -import { updatePlaylistArtwork } from '~/utils/updatePlaylistArtwork' - -import { TQCollection } from '../models' -import { primeCollectionData } from '../utils/primeCollectionData' - -type MutationContext = { - previousCollection: TQCollection | undefined - collectionUpdate: EditCollectionValues -} - -type UpdateCollectionParams = { - collectionId: ID - metadata: EditCollectionValues -} - -export const useUpdateCollection = () => { - const { - audiusSdk, - imageUtils: { generatePlaylistArtwork } - } = useQueryContext() - const queryClient = useQueryClient() - const dispatch = useDispatch() - const { data: currentUserId } = useCurrentUserId() - - return useMutation({ - mutationFn: async ({ collectionId, metadata }: UpdateCollectionParams) => { - const sdk = await audiusSdk() - - if (!collectionId || !currentUserId) throw new Error('Invalid ID') - - const collectionUpdate = (await updatePlaylistArtwork( - metadata, - [], - { updated: metadata.tracks }, - { generateImage: generatePlaylistArtwork } - )) as EditCollectionValues - - const coverArtFile = - collectionUpdate?.artwork?.url && 'file' in collectionUpdate.artwork - ? (collectionUpdate.artwork.file as File) - : undefined - - // Handle account collection shortcut update - if (collectionUpdate?.playlist_name) { - dispatch( - renameAccountPlaylist({ - collectionId, - name: collectionUpdate.playlist_name - }) - ) - } - - // Handle premium metadata for albums - if ( - collectionUpdate.is_album && - isContentUSDCPurchaseGated(collectionUpdate.stream_conditions) - ) { - const priceCents = Number( - collectionUpdate.stream_conditions.usdc_purchase.price - ) - - // Update the stream conditions with the price and splits - collectionUpdate.stream_conditions = { - usdc_purchase: { - price: priceCents, - splits: [ - { - user_id: currentUserId, - percentage: 100 - } - ] - } - } - } - - const sdkMetadata = playlistMetadataForUpdateWithSDK( - collectionUpdate as Collection - ) - - const response = await sdk.playlists.updatePlaylist({ - imageFile: coverArtFile - ? fileToSdk(coverArtFile, 'cover_art') - : undefined, - playlistId: Id.parse(collectionId), - userId: Id.parse(currentUserId), - metadata: sdkMetadata - }) - - // feature-tan-query TODO: Track publishing when making private collections public - - return response - }, - onMutate: async ({ - collectionId, - metadata - }: UpdateCollectionParams): Promise => { - // Cancel any outgoing refetches - await queryClient.cancelQueries({ - queryKey: getCollectionQueryKey(collectionId) - }) - - // Snapshot the previous values - const previousCollection = queryClient.getQueryData( - getCollectionQueryKey(collectionId) - ) - - const previousTracks = - previousCollection?.trackIds - .map((trackId) => queryClient.getQueryData(getTrackQueryKey(trackId))) - .filter(removeNullable) ?? [] - - // Optimistically update collection - const mergedCollection = { ...previousCollection, ...metadata } - const collectionUpdate = (await updatePlaylistArtwork( - mergedCollection, - previousTracks, - { updated: mergedCollection.tracks }, - { generateImage: generatePlaylistArtwork } - )) as EditCollectionValues - - if (previousCollection) { - primeCollectionData({ - collections: [{ ...previousCollection, ...metadata }], - queryClient, - forceReplace: true - }) - - const previousTrackIds = previousTracks.map((track) => track.track_id) - const updatedTrackIds = collectionUpdate.tracks?.map( - (track) => track.track_id - ) - if (!isEqual(previousTrackIds, updatedTrackIds)) { - // feature-tan-query TODO: reset lineup on tracks changed - } - } - - // Return context with the previous collection - return { previousCollection, collectionUpdate } - }, - onError: (_err, _, context?: MutationContext) => { - // If the mutation fails, roll back collection data - if (context?.previousCollection) { - primeCollectionData({ - collections: [context.previousCollection], - queryClient, - forceReplace: true - }) - } - }, - onSettled: (_, __, { collectionId }) => { - // Always refetch after error or success to ensure cache is in sync with server - queryClient.invalidateQueries({ queryKey: ['collection', collectionId] }) - } - }) -} diff --git a/packages/common/src/api/tan-query/comments/useComments.ts b/packages/common/src/api/tan-query/comments/useComments.ts index 41e5b610e17..cb96204b222 100644 --- a/packages/common/src/api/tan-query/comments/useComments.ts +++ b/packages/common/src/api/tan-query/comments/useComments.ts @@ -5,17 +5,13 @@ import { keyBy } from 'lodash' import { ID } from '~/models/Identifiers' -import { QueryKey, QueryOptions } from '../types' +import { QueryOptions } from '../types' import { combineQueryResults } from '../utils/combineQueryResults' import { useQueries } from '../utils/useQueries' import { CommentOrReply } from './types' import { getCommentQueryKey } from './utils' -export const getCommentsQueryKey = (commentIds: ID[] | null | undefined) => { - return ['comments', commentIds] as unknown as QueryKey -} - export const useComments = ( commentIds: ID[] | null | undefined, options?: QueryOptions diff --git a/packages/common/src/api/tan-query/events/useAllRemixContests.ts b/packages/common/src/api/tan-query/events/useAllRemixContests.ts index 22c2e41e101..77fc04e0fb3 100644 --- a/packages/common/src/api/tan-query/events/useAllRemixContests.ts +++ b/packages/common/src/api/tan-query/events/useAllRemixContests.ts @@ -45,7 +45,7 @@ export const getAllRemixContestsQueryKey = ({ /** * Hook to fetch all remix contest events with infinite query support. - * Calls the dedicated discovery endpoint `GET /v1/events/remix-contests` + * Calls the dedicated validator node endpoint `GET /v1/events/remix-contests` * (SDK: `events.getRemixContests`), which returns events ordered with * currently-active contests first (by soonest-ending end_date) followed by * ended contests. @@ -85,7 +85,7 @@ export const useAllRemixContests = ( }) // Prime related tracks + users (full objects, delivered alongside the - // event list on the discovery endpoint). This turns ContestCard's + // event list on the validator node endpoint). This turns ContestCard's // useTrack / useUser into cache hits so the grid can paint with one // network round-trip instead of N+1. primeRelatedData({ related, queryClient }) diff --git a/packages/common/src/api/tan-query/jupiter/solanaUtils.ts b/packages/common/src/api/tan-query/jupiter/solanaUtils.ts index 3d6b3ce0e23..b8482ee7f2b 100644 --- a/packages/common/src/api/tan-query/jupiter/solanaUtils.ts +++ b/packages/common/src/api/tan-query/jupiter/solanaUtils.ts @@ -2,8 +2,6 @@ import type { AudiusSdkWithServices } from '@audius/sdk' import { SwapInstructionsResponse, SwapRequest } from '@jup-ag/api' import { createAssociatedTokenAccountIdempotentInstruction, - createCloseAccountInstruction, - createTransferCheckedInstruction, getAccount, getAssociatedTokenAddressSync } from '@solana/spl-token' @@ -15,10 +13,7 @@ import { VersionedTransaction } from '@solana/web3.js' -import { - getJupiterQuoteByMintWithRetry, - jupiterInstance -} from '~/services/Jupiter' +import { jupiterInstance } from '~/services/Jupiter' import { INTERNAL_TRANSFER_MEMO_STRING, MEMO_PROGRAM_ID @@ -101,46 +96,6 @@ export async function addTransferFromUserBankInstructions({ return ata } -export async function addTransferToUserBankInstructions({ - tokenInfo, - userPublicKey, - ethAddress, - amountLamports, - sourceAta, - sdk, - feePayer, - instructions -}: { - tokenInfo: UserBankManagedTokenInfo - userPublicKey: PublicKey - ethAddress: string - amountLamports: bigint - sourceAta: PublicKey - sdk: AudiusSdkWithServices - feePayer: PublicKey - instructions: TransactionInstruction[] -}): Promise { - const mint = new PublicKey(tokenInfo.mintAddress) - const userBankAddress = - await sdk.services.claimableTokensClient.deriveUserBank({ - ethWallet: ethAddress, - mint: tokenInfo.claimableTokenMint - }) - - instructions.push( - createTransferCheckedInstruction( - sourceAta, - mint, - userBankAddress, - userPublicKey, - amountLamports, - tokenInfo.decimals - ), - createCloseAccountInstruction(sourceAta, feePayer, userPublicKey) - ) - return userBankAddress -} - /** * Creates an Associated Token Account (ATA) for Jupiter when shared accounts are not supported. * This is used as a fallback when Jupiter's shared account system fails for simple AMMs. @@ -313,44 +268,3 @@ export const prepareOutputUserBank = async ( }) return result.userBank.toBase58() } - -/** - @deprecated - We're moving away from Jupiter as the SO for stuff - use getIsDirectSwappable instead + meteora quotes if needed -*/ -export const isDirectRouteAvailable = async ( - inputMint: string, - outputMint: string, - amountUi: number, - tokens: Record -): Promise => { - try { - // Validate tokens and create configs - const tokenConfigsResult = validateAndCreateTokenConfigs( - inputMint, - outputMint, - tokens - ) - - if ('error' in tokenConfigsResult) { - return false - } - - const { inputTokenConfig, outputTokenConfig } = tokenConfigsResult - - // Try to get a direct quote - await getJupiterQuoteByMintWithRetry({ - inputMint, - outputMint, - inputDecimals: inputTokenConfig.decimals, - outputDecimals: outputTokenConfig.decimals, - amountUi, - swapMode: 'ExactIn', - onlyDirectRoutes: false - }) - - return true - } catch (error) { - // If quote fails, there's no direct path available - return false - } -} diff --git a/packages/common/src/api/tan-query/lineups/usePremiumTracks.ts b/packages/common/src/api/tan-query/lineups/usePremiumTracks.ts deleted file mode 100644 index be072cee47e..00000000000 --- a/packages/common/src/api/tan-query/lineups/usePremiumTracks.ts +++ /dev/null @@ -1,96 +0,0 @@ -import { useMemo } from 'react' - -import { OptionalId, EntityType } from '@audius/sdk' -import { - InfiniteData, - useInfiniteQuery, - useQueryClient -} from '@tanstack/react-query' - -import { userTrackMetadataFromSDK } from '~/adapters/track' -import { transformAndCleanList } from '~/adapters/utils' -import { useQueryContext } from '~/api/tan-query/utils' -import { ID } from '~/models/Identifiers' - -import { QUERY_KEYS } from '../queryKeys' -import { QueryKey, LineupData, QueryOptions } from '../types' -import { useCurrentUserId } from '../users/account/useCurrentUserId' -import { useLoadNextPage } from '../utils/infiniteQueryLoadNextPage' -import { primeTrackData } from '../utils/primeTrackData' - -const DEFAULT_PAGE_SIZE = 10 - -type UsePremiumTracksArgs = { - pageSize?: number -} - -export const getPremiumTracksQueryKey = (pageSize: number) => { - return [QUERY_KEYS.premiumTracks, pageSize] as unknown as QueryKey< - InfiniteData - > -} - -export const usePremiumTracks = ( - { pageSize = DEFAULT_PAGE_SIZE }: UsePremiumTracksArgs = {}, - options?: QueryOptions -) => { - const { audiusSdk } = useQueryContext() - const { data: currentUserId } = useCurrentUserId() - const queryClient = useQueryClient() - - const queryKey = getPremiumTracksQueryKey(pageSize) - - const query = useInfiniteQuery({ - queryKey, - initialPageParam: 0, - getNextPageParam: (lastPage: LineupData[], allPages) => { - if (lastPage.length < pageSize) return undefined - return allPages.length * pageSize - }, - queryFn: async ({ pageParam }) => { - const sdk = await audiusSdk() - const { data: tracks = [] } = - await sdk.tracks.getTrendingUSDCPurchaseTracks({ - userId: OptionalId.parse(currentUserId), - limit: pageSize, - offset: pageParam - }) - const processedTracks = transformAndCleanList( - tracks, - userTrackMetadataFromSDK - ) - primeTrackData({ tracks: processedTracks, queryClient }) - return processedTracks.map((t) => ({ - id: t.track_id, - type: EntityType.TRACK - })) - }, - select: (data) => data?.pages.flat(), - ...options, - enabled: options?.enabled !== false - }) - - const data = useMemo(() => query.data ?? [], [query.data]) - const trackIds = useMemo( - () => - data.filter((d) => d.type === EntityType.TRACK).map((d) => d.id as ID), - [data] - ) - - const loadNextPage = useLoadNextPage(query) - - return { - data, - trackIds, - isPending: query.isPending, - isLoading: query.isLoading, - isFetching: query.isFetching, - isSuccess: query.isSuccess, - isError: query.isError, - isInitialLoading: query.isInitialLoading, - hasNextPage: query.hasNextPage, - fetchNextPage: query.fetchNextPage, - loadNextPage, - queryKey - } -} diff --git a/packages/common/src/api/tan-query/playlist-updates/usePlaylistUpdates.ts b/packages/common/src/api/tan-query/playlist-updates/usePlaylistUpdates.ts index 6a090008574..07ec3daa84b 100644 --- a/packages/common/src/api/tan-query/playlist-updates/usePlaylistUpdates.ts +++ b/packages/common/src/api/tan-query/playlist-updates/usePlaylistUpdates.ts @@ -81,11 +81,3 @@ export const useAllPlaylistUpdateIds = () => usePlaylistUpdates({ select: (updates) => updates.map((u) => u.playlist_id) }) - -/** - * Returns the count of playlists with unviewed updates. - */ -export const usePlaylistUpdatesCount = () => - usePlaylistUpdates({ - select: (updates) => updates.length - }) diff --git a/packages/common/src/api/tan-query/purchases/useUSDCTransactions.ts b/packages/common/src/api/tan-query/purchases/useUSDCTransactions.ts index 70bc0d597f0..4bad9d8a24d 100644 --- a/packages/common/src/api/tan-query/purchases/useUSDCTransactions.ts +++ b/packages/common/src/api/tan-query/purchases/useUSDCTransactions.ts @@ -140,8 +140,6 @@ export const useUSDCTransactions = ( }) }, [queryClient, queryKey]) - // @ts-ignore - queryData.reset = reset // Stable identity for loadNextPage so the consuming Table's `loadMoreRows` // doesn't change every render. We read the latest queryData from a ref // at call time instead of capturing it in the closure deps. @@ -152,9 +150,12 @@ export const useUSDCTransactions = ( if (q.isFetching || !q.hasNextPage) return undefined return q.fetchNextPage() }, []) - // @ts-ignore - queryData.loadNextPage = loadNextPageCallback - return queryData as UseInfiniteQueryResult & { + // Attach helpers directly onto the query result object (rather than + // spreading it) so TanStack Query's tracked-property access keeps working. + return Object.assign(queryData, { + reset, + loadNextPage: loadNextPageCallback + }) as UseInfiniteQueryResult & { reset: typeof reset loadNextPage: typeof loadNextPageCallback } diff --git a/packages/common/src/api/tan-query/reactions/utils.ts b/packages/common/src/api/tan-query/reactions/utils.ts deleted file mode 100644 index 65b2304a361..00000000000 --- a/packages/common/src/api/tan-query/reactions/utils.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { ReactionTypes, reactionsMap } from './types' - -export const getReactionFromRawValue = ( - value: number | null -): ReactionTypes | null => { - if (value === null) return null - const val = (Object.entries(reactionsMap) as [ReactionTypes, number][]).find( - ([_k, v]) => v === value - ) - return val?.[0] ?? null -} - -export const getRawValueFromReaction = ( - reaction: ReactionTypes | null -): number | null => { - if (reaction === null) return null - return reactionsMap[reaction] ?? null -} diff --git a/packages/common/src/api/tan-query/saga-utils/queryCollection.ts b/packages/common/src/api/tan-query/saga-utils/queryCollection.ts index 6dc4b5caab3..8256ecb87b0 100644 --- a/packages/common/src/api/tan-query/saga-utils/queryCollection.ts +++ b/packages/common/src/api/tan-query/saga-utils/queryCollection.ts @@ -78,22 +78,3 @@ export function* queryCollectionByPermalink( const collection = yield* call(queryCollection, collectionId, queryOptions) return collection } - -export function* queryCollectionsByPermalink( - permalinks: string[], - queryOptions?: QueryOptions -) { - const collections = {} as Record - for (const permalink of permalinks) { - // Call each queryCollectionByPermalink individually. They will be batched together in the queryFn (if necessary) - const collection = yield* call( - queryCollectionByPermalink, - permalink, - queryOptions - ) - if (collection) { - collections[permalink] = collection - } - } - return collections -} diff --git a/packages/common/src/api/tan-query/saga-utils/queryTrack.ts b/packages/common/src/api/tan-query/saga-utils/queryTrack.ts index 358456f30d8..b1b3fc3bcf7 100644 --- a/packages/common/src/api/tan-query/saga-utils/queryTrack.ts +++ b/packages/common/src/api/tan-query/saga-utils/queryTrack.ts @@ -4,7 +4,7 @@ import { Track } from '~/models' import { ID } from '~/models/Identifiers' import { getContext } from '~/store/effects' import { getSDK } from '~/store/sdkUtils' -import { removeNullable, Uid } from '~/utils' +import { removeNullable } from '~/utils' import { TQTrack } from '../models' import { QUERY_KEYS } from '../queryKeys' @@ -69,12 +69,6 @@ export function* queryAllTracks() { ) } -export function* queryTrackByUid(uid: string | null | undefined) { - if (!uid) return null - const trackId = Number(Uid.fromString(uid).id) - return yield* queryTrack(trackId) -} - export function* queryCollectionTracks( collectionId: ID | null | undefined, queryOptions?: QueryOptions diff --git a/packages/common/src/api/tan-query/saga-utils/queryUser.ts b/packages/common/src/api/tan-query/saga-utils/queryUser.ts index 8f5f0fbfff1..ea97570b8dc 100644 --- a/packages/common/src/api/tan-query/saga-utils/queryUser.ts +++ b/packages/common/src/api/tan-query/saga-utils/queryUser.ts @@ -5,7 +5,6 @@ import { User } from '~/models/User' import { getContext } from '~/store/effects' import { getSDK } from '~/store/sdkUtils' -import { QUERY_KEYS } from '../queryKeys' import { getUserQueryFn, getUserQueryKey } from '../users/useUser' import { getUserByHandleQueryFn, @@ -80,19 +79,3 @@ export function* queryUsers(ids: ID[], queryOptions?: QueryOptions) { return users } - -export function* queryAllCachedUsers() { - const queryClient = yield* getContext('queryClient') - const queries = queryClient.getQueriesData({ - queryKey: [QUERY_KEYS.user] - }) - return queries.reduce( - (acc, [_, user]) => { - if (user?.user_id) { - acc[user.user_id] = user - } - return acc - }, - {} as Record - ) -} diff --git a/packages/common/src/api/tan-query/tracks/useTracks.ts b/packages/common/src/api/tan-query/tracks/useTracks.ts index 9226c79e5e9..3403f2434c2 100644 --- a/packages/common/src/api/tan-query/tracks/useTracks.ts +++ b/packages/common/src/api/tan-query/tracks/useTracks.ts @@ -7,7 +7,6 @@ import { useDispatch } from 'react-redux' import { useQueryContext } from '~/api/tan-query/utils' import { ID } from '~/models/Identifiers' -import { getTracksBatcher } from '../batchers/getTracksBatcher' import { TQTrack } from '../models' import { QueryOptions } from '../types' import { useCurrentUserId } from '../users/account/useCurrentUserId' @@ -17,26 +16,6 @@ import { useQueries } from '../utils/useQueries' import { getTrackQueryFn, getTrackQueryKey } from './useTrack' -// This function is only used for batch operations in saga utilities -export const getTracksQueryFn = async ( - trackIds: ID[], - currentUserId: ID | null, - queryClient: any, - sdk: any, - dispatch: any -) => { - const batchGetTracks = getTracksBatcher({ - sdk, - currentUserId, - queryClient, - dispatch - }) - const tracks = await Promise.all( - trackIds.map((trackId) => batchGetTracks.fetch(trackId)) - ) - return tracks.filter((track): track is TQTrack => !!track) -} - export const useTracks = ( trackIds: ID[] | null | undefined, options?: QueryOptions diff --git a/packages/common/src/api/tan-query/users/useUnfollowUser.ts b/packages/common/src/api/tan-query/users/useUnfollowUser.ts deleted file mode 100644 index ddcb2650176..00000000000 --- a/packages/common/src/api/tan-query/users/useUnfollowUser.ts +++ /dev/null @@ -1,120 +0,0 @@ -import { Id } from '@audius/sdk' -import { useMutation, useQueryClient } from '@tanstack/react-query' -import { useDispatch } from 'react-redux' - -import { useQueryContext } from '~/api/tan-query/utils/QueryContext' -import { useAppContext } from '~/context/appContext' -import { Name, FollowSource } from '~/models/Analytics' -import { ID } from '~/models/Identifiers' -import { UserMetadata } from '~/models/User' -import { removeFolloweeId } from '~/store/gated-content/slice' - -import { primeUserData } from '../utils/primeUserData' - -import { useCurrentUserId } from './account/useCurrentUserId' -import { getUserQueryKey } from './useUser' - -type UnfollowUserParams = { - followeeUserId: ID | null | undefined - source: FollowSource -} - -type MutationContext = { - previousUser: UserMetadata | undefined -} - -export const useUnfollowUser = () => { - const { audiusSdk } = useQueryContext() - const queryClient = useQueryClient() - const dispatch = useDispatch() - const { - analytics: { track, make } - } = useAppContext() - const { data: currentUserId } = useCurrentUserId() - - return useMutation({ - mutationFn: async ({ followeeUserId, source }: UnfollowUserParams) => { - if (!currentUserId || !followeeUserId) { - return - } - - const sdk = await audiusSdk() - await sdk.users.unfollowUser({ - userId: Id.parse(currentUserId), - followeeUserId: Id.parse(followeeUserId) - }) - - // Handle gated content - dispatch(removeFolloweeId({ id: followeeUserId })) - - if (source) { - track( - make({ - eventName: Name.UNFOLLOW, - id: followeeUserId.toString(), - source - }) - ) - } - }, - onMutate: async ({ followeeUserId }) => { - if (!followeeUserId || !currentUserId) { - return { previousUser: undefined } - } - - await queryClient.cancelQueries({ - queryKey: getUserQueryKey(followeeUserId) - }) - - const previousUser = queryClient.getQueryData( - getUserQueryKey(followeeUserId) - ) - - const followeeUpdate = { - does_current_user_follow: false, - follower_count: Math.max((previousUser?.follower_count ?? 0) - 1, 0) - } - if (previousUser) { - const updatedUser = { - ...previousUser, - ...followeeUpdate - } - primeUserData({ - users: [updatedUser], - queryClient, - forceReplace: true - }) - } - - const currentUser = queryClient.getQueryData( - getUserQueryKey(currentUserId) - ) - if (currentUser) { - const updatedCurrentUser = { - ...currentUser, - followee_count: Math.max((currentUser?.followee_count ?? 0) - 1, 0) - } - primeUserData({ - users: [updatedCurrentUser], - queryClient, - forceReplace: true - }) - } - - return { previousUser } - }, - onError: (error, _args, context: MutationContext | undefined) => { - const { previousUser } = context ?? {} - - if (previousUser) { - primeUserData({ - users: [previousUser], - queryClient, - forceReplace: true - }) - } - - console.error(error) - } - }) -} diff --git a/packages/common/src/api/tan-query/users/useUpdateProfile.ts b/packages/common/src/api/tan-query/users/useUpdateProfile.ts index 51a878060e3..2bf454b240a 100644 --- a/packages/common/src/api/tan-query/users/useUpdateProfile.ts +++ b/packages/common/src/api/tan-query/users/useUpdateProfile.ts @@ -84,7 +84,7 @@ export const useUpdateProfile = () => { onSuccess: (_data, variables) => { // Re-confirm the mutation in the cache after server success. // We re-apply mutation variables rather than the raw server response - // to guard against discovery-node propagation lag: the node answering + // to guard against validator node propagation lag: the node answering // getUser may not yet have indexed the confirmed block. const currentCache = queryClient.getQueryData( getUserQueryKey(currentUserId) diff --git a/packages/common/src/api/tan-query/users/useUpdateUser.ts b/packages/common/src/api/tan-query/users/useUpdateUser.ts index b1236f66ffd..79ff25891e0 100644 --- a/packages/common/src/api/tan-query/users/useUpdateUser.ts +++ b/packages/common/src/api/tan-query/users/useUpdateUser.ts @@ -75,10 +75,6 @@ export const useUpdateUser = () => { forceReplace: true }) } - }, - onSettled: (_, __) => { - // Always refetch after error or success to ensure cache is in sync with server - // queryClient.invalidateQueries({ queryKey: ['user', userId] }) } }) } diff --git a/packages/common/src/api/tan-query/users/useUser.ts b/packages/common/src/api/tan-query/users/useUser.ts index 7b4cf069fe9..dd865597a2a 100644 --- a/packages/common/src/api/tan-query/users/useUser.ts +++ b/packages/common/src/api/tan-query/users/useUser.ts @@ -20,14 +20,6 @@ export const getUserQueryKey = (userId: ID | null | undefined) => { return [QUERY_KEYS.user, userId] as unknown as QueryKey } -export const getUserComputedPropsQueryKey = (userId: ID | null | undefined) => { - return [ - QUERY_KEYS.user, - userId, - QUERY_KEYS.computedProps - ] as unknown as QueryKey -} - export const getUserQueryFn = async ( userId: ID, currentUserId: ID | null | undefined, diff --git a/packages/common/src/api/tan-query/wallets/useAudioBalance.ts b/packages/common/src/api/tan-query/wallets/useAudioBalance.ts index 1799f70fb8a..6925c10ec07 100644 --- a/packages/common/src/api/tan-query/wallets/useAudioBalance.ts +++ b/packages/common/src/api/tan-query/wallets/useAudioBalance.ts @@ -308,92 +308,6 @@ export function* getAccountAudioBalanceSaga() { return yield* call(getWalletBalances, userWallets) } -/** - * Sums current audio account balance combined with balance from all connected wallets - * @returns - */ -export function* getAccountTotalAudioBalanceSaga() { - const queryClient = yield* getContext('queryClient') - const queryContext = yield* getQueryContext() - const accountBalance = yield* call(getAccountAudioBalanceSaga) - const currentUserId = yield* call(queryCurrentUserId) - const fetchConnectedWallets = async () => - await queryClient.fetchQuery( - getConnectedWalletsQueryOptions(queryContext, { - userId: currentUserId - }) - ) - const connectedWallets = yield* call(fetchConnectedWallets) - const connectedWalletsBalance = yield* call( - getWalletBalances, - connectedWallets ?? [] - ) - - return AUDIO(accountBalance + connectedWalletsBalance).value -} - -/** - * Optimistically updates the user's SOL wallet balance in the cache. - * Use this to provide immediate UI feedback before the transaction confirms. - * - * @param amount - The amount to add (positive) or subtract (negative) from the current balance - */ -export function* optimisticallyUpdateUserWAudioBalance(change: AudioWei) { - const queryClient = yield* getContext('queryClient') - const queryContext = yield* getQueryContext() - const currentUserId = yield* call(queryCurrentUserId) - const user = yield* call(queryUser, currentUserId) - - if (!user?.spl_wallet) return - - // Update both staked and non-staked balance queries for the SOL wallet - for (const includeStaked of [true, false]) { - const { queryKey } = getWalletAudioBalanceOptions(queryContext, { - address: user.spl_wallet, - chain: Chain.Sol, - includeStaked - }) - - queryClient.setQueryData(queryKey, (oldBalance) => { - const currentBalance = oldBalance ?? AUDIO(0).value - const newBalance = AUDIO(currentBalance + change).value - // Ensure balance doesn't go negative - return newBalance >= 0 ? newBalance : AUDIO(0).value - }) - } -} - -/** - * Reverts an optimistic balance update by invalidating the cache. - * Use this when a transaction fails and you need to revert to the real balance. - */ -export function* revertOptimisticUserSolBalance() { - const queryClient = yield* getContext('queryClient') - const currentUserId = yield* call(queryCurrentUserId) - const user = yield* call(queryUser, currentUserId) - - if (!user?.spl_wallet) return - - // Invalidate both staked and non-staked balance queries - const solWalletQueries = [ - { - address: user.spl_wallet, - chain: Chain.Sol, - includeStaked: true - }, - { - address: user.spl_wallet, - chain: Chain.Sol, - includeStaked: false - } - ] - - for (const queryParams of solWalletQueries) { - const queryKey = getWalletAudioBalanceQueryKey(queryParams) - queryClient.invalidateQueries({ queryKey }) - } -} - /** * Optimistically updates the AUDIO balance for a SOL wallet in React Query cache. * Updates both staked and non-staked balance queries. diff --git a/packages/common/src/hooks/useInstanceVar.ts b/packages/common/src/hooks/useInstanceVar.ts index 167a46f2aa9..f2c72c04df3 100644 --- a/packages/common/src/hooks/useInstanceVar.ts +++ b/packages/common/src/hooks/useInstanceVar.ts @@ -19,8 +19,7 @@ export const useInstanceVar = ( const setter = useCallback( (updated: T | ((old: T) => T)) => { if (typeof updated === 'function') { - // @ts-ignore - ref.current = updated(ref.current) + ref.current = (updated as (old: T) => T)(ref.current) } else { ref.current = updated } diff --git a/packages/common/src/models/Activity.ts b/packages/common/src/models/Activity.ts deleted file mode 100644 index 10b4933c789..00000000000 --- a/packages/common/src/models/Activity.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { UserCollectionMetadata } from './Collection' -import { UserTrackMetadata } from './Track' - -export type CollectionActivity = { - timestamp: string - item_type: 'playlist' - item?: UserCollectionMetadata -} - -export type TrackActivity = { - timestamp: string - item_type: 'track' - item?: UserTrackMetadata -} - -export type RepostActivity = CollectionActivity | TrackActivity diff --git a/packages/common/src/models/Status.ts b/packages/common/src/models/Status.ts index b5dd1f352c5..82b1981a7dc 100644 --- a/packages/common/src/models/Status.ts +++ b/packages/common/src/models/Status.ts @@ -13,19 +13,3 @@ export enum PaginatedStatus { export function statusIsNotFinalized(status: Status) { return [Status.IDLE, Status.LOADING].includes(status) } - -/** - * Reduces an array of `Status` values to the least-complete status or `ERROR` if present. - */ -export function combineStatuses(statuses: Status[]) { - if (statuses.includes(Status.ERROR)) { - return Status.ERROR - } - if (statuses.includes(Status.LOADING)) { - return Status.LOADING - } - if (statuses.includes(Status.IDLE)) { - return Status.IDLE - } - return Status.SUCCESS -} diff --git a/packages/common/src/models/Track.ts b/packages/common/src/models/Track.ts index afeeff48ec7..407ea58b605 100644 --- a/packages/common/src/models/Track.ts +++ b/packages/common/src/models/Track.ts @@ -115,11 +115,6 @@ export const isContentTokenGated = ( ): gatedConditions is TokenGatedConditions => !!gatedConditions && 'token_gate' in (gatedConditions ?? {}) -export const isContentNftGated = ( - gatedConditions?: Nullable -): gatedConditions is NftGatedConditions => - !!gatedConditions && 'nft_collection' in (gatedConditions ?? {}) - export const isContentUSDCPurchaseGated = ( gatedConditions?: Nullable< AccessConditions | DeepOmit diff --git a/packages/common/src/services/audius-backend/AudiusBackend.ts b/packages/common/src/services/audius-backend/AudiusBackend.ts index fd535eadedd..a78752ec45b 100644 --- a/packages/common/src/services/audius-backend/AudiusBackend.ts +++ b/packages/common/src/services/audius-backend/AudiusBackend.ts @@ -344,7 +344,7 @@ export const audiusBackend = ({ } /** - * Records a first-party internal notification campaign push open in Discovery (API). + * Records a first-party internal notification campaign push open via the validator node API. * Fire-and-forget; failures are logged and swallowed. */ async function reportNotificationCampaignPushOpen({ diff --git a/packages/common/src/services/oauth/formatSocialProfile.ts b/packages/common/src/services/oauth/formatSocialProfile.ts index 666baf21351..d95cf56dc49 100644 --- a/packages/common/src/services/oauth/formatSocialProfile.ts +++ b/packages/common/src/services/oauth/formatSocialProfile.ts @@ -1,4 +1,4 @@ -import { TikTokProfile, TwitterProfile } from '~/store/account/types' +import { TikTokProfile } from '~/store/account/types' export const MAX_HANDLE_LENGTH = 30 export const MAX_DISPLAY_NAME_LENGTH = 32 @@ -7,67 +7,6 @@ export const MAX_DISPLAY_NAME_LENGTH = 32 // indexer rejects bios longer than this with IndexingValidationError. export const MAX_BIO_LENGTH = 256 -export const formatTwitterProfile = async ( - twitterProfile: TwitterProfile, - resizeImage: ( - image: File, - maxWidth?: number, - square?: boolean, - key?: string - ) => Promise -) => { - const profileUrl = twitterProfile.profile_image_url_https.replace( - /_(normal|bigger|mini)/g, - '' - ) - const imageBlob = await fetch(profileUrl).then((r) => r.blob()) - const artworkFile = new File([imageBlob], 'Artwork', { - type: 'image/jpeg' - }) - const file = await resizeImage(artworkFile) - const url = URL.createObjectURL(file) - - let bannerUrl, bannerFile - if (twitterProfile.profile_banner_url) { - const bannerImageBlob = await fetch(twitterProfile.profile_banner_url).then( - (r) => r.blob() - ) - const bannerArtworkFile = new File([bannerImageBlob], 'Artwork', { - type: 'image/webp' - }) - bannerFile = await resizeImage(bannerArtworkFile, 2000, false) - bannerUrl = URL.createObjectURL(bannerFile) - } - // Truncate to MAX_HANDLE_LENGTH characters because we don't support longer handles. - // If the user is verifed, they won't be able to claim the status if - // the handle doesn't match, so just pass through. - let requiresUserReview = false - let handleTooLong = false - - if (twitterProfile.screen_name.length > MAX_HANDLE_LENGTH) { - requiresUserReview = true - handleTooLong = true - if (!twitterProfile.verified) { - twitterProfile.screen_name = twitterProfile.screen_name.slice( - 0, - MAX_HANDLE_LENGTH - ) - } - } - if (twitterProfile.name.length > MAX_DISPLAY_NAME_LENGTH) { - requiresUserReview = true - twitterProfile.name = twitterProfile.name.slice(0, MAX_DISPLAY_NAME_LENGTH) - } - - return { - profile: twitterProfile, - profileImage: { url, file }, - profileBanner: bannerUrl ? { url: bannerUrl, file: bannerFile } : undefined, - requiresUserReview, - handleTooLong - } -} - export const formatTikTokProfile = async ( tikTokProfile: TikTokProfile, resizeImage: ( diff --git a/packages/common/src/services/remote-config/types.ts b/packages/common/src/services/remote-config/types.ts index 3d327ed46aa..20b34699d27 100644 --- a/packages/common/src/services/remote-config/types.ts +++ b/packages/common/src/services/remote-config/types.ts @@ -32,12 +32,12 @@ export enum IntKeys { CLIENT_ATTESTATION_PARALLELIZATION = 'CLIENT_ATTESTATION_PARALLELIZATION', /** - * The time to spend polling DN for updates to the challenge being claimed to check if it has been indexed as complete. + * The time to spend polling the validator node for updates to the challenge being claimed to check if it has been indexed as complete. */ CHALLENGE_CLAIM_COMPLETION_POLL_TIMEOUT_MS = 'CHALLENGE_CLAIM_COMPLETION_POLL_TIMEOUT_MS', /** - * The interval between polls to DN for updates to the challenge being claimed to check if it has been indexed as complete. + * The interval between polls to the validator node for updates to the challenge being claimed to check if it has been indexed as complete. */ CHALLENGE_CLAIM_COMPLETION_POLL_FREQUENCY_MS = 'CHALLENGE_CLAIM_COMPLETION_POLL_FREQUENCY_MS', diff --git a/packages/common/src/store/account/sagas.ts b/packages/common/src/store/account/sagas.ts index 7ed80bd72f7..07cd3683f7e 100644 --- a/packages/common/src/store/account/sagas.ts +++ b/packages/common/src/store/account/sagas.ts @@ -375,7 +375,7 @@ function* setLocalStorageAccountAndUser( // Prefer cached user data (which may include recent optimistic mutations // like profile_type changes) over the server-fetched response. This prevents // setLocalStorageAccountAndUser from overwriting changes that haven't yet - // propagated to all discovery nodes. + // propagated to all validator nodes. const queryClient = yield* getContext('queryClient') const cachedUser = queryClient.getQueryData( getUserQueryKey(accountUser.user_id) diff --git a/packages/common/src/store/pages/audio-rewards/selectors.ts b/packages/common/src/store/pages/audio-rewards/selectors.ts index c256e695e24..8ed68abfeb7 100644 --- a/packages/common/src/store/pages/audio-rewards/selectors.ts +++ b/packages/common/src/store/pages/audio-rewards/selectors.ts @@ -62,4 +62,3 @@ export const getHCaptchaStatus = (state: CommonState) => export const getShowRewardClaimedToast = (state: CommonState) => state.pages.audioRewards.showRewardClaimedToast - diff --git a/packages/common/src/store/sagas.ts b/packages/common/src/store/sagas.ts index 4c5d72b2448..d59461d0d7b 100644 --- a/packages/common/src/store/sagas.ts +++ b/packages/common/src/store/sagas.ts @@ -1,11 +1,3 @@ -// import collectionsErrorSagas from 'common/store/cache/collections/errorSagas' -// import collectionsSagas from 'common/store/cache/collections/sagas' -// import cacheSagas from 'common/store/cache/sagas' -// import tracksSagas from 'common/store/cache/tracks/sagas' -// import usersSagas from 'common/store/cache/users/sagas' -// import recoveryEmailSagas from 'common/store/recovery-email/sagas' -// import signOutSagas from 'common/store/sign-out/sagas' - import niceModalBridgeSagas from '~/services/nice-modal-bridge/sagas' import { accountSagas } from '~/store/account' import { buyUSDCSagas } from '~/store/buy-usdc' @@ -49,53 +41,4 @@ export const sagas = (_ctx: CommonStoreContext) => ({ duplidateAddConfirmationModalUI: duplicateAddConfirmationModalUISagas, withdrawUSDC: withdrawUSDCSagas, niceModalBridge: niceModalBridgeSagas - - // signOut: signOutSagas - // recoveryEmail: recoveryEmailSagas - // TODO: - // pull in the following from web - // once AudiusBackend and dependencies are migrated - // ./pages/explore/exploreCollections/sagas.ts - // ./pages/explore/sagas.ts - // components/add-to-collection/store/sagas.ts - // components/share-sound-to-tiktok-modal/store/sagas.ts - // store/social/tracks/sagas.ts - // store/social/users/sagas.ts - // store/social/collections/sagas.ts - // pages/audio-rewards-page/store/sagas.ts - // store/wallet/sagas.ts - // store/lineup/sagas.js - // pages/feed/store/lineups/feed/sagas.js - // pages/feed/store/sagas.js - // pages/collection/store/lineups/tracks/sagas.js - // pages/collection/store/sagas.js - // pages/track/store/lineups/tracks/sagas.js - // pages/track/store/sagas.js - // store/ui/stemsUpload/sagas.ts - // pages/user-list/followers/sagas.ts - // pages/user-list/following/sagas.ts - // pages/user-list/reposts/sagas.ts - // pages/user-list/favorites/sagas.ts - // pages/user-list/mutuals/sagas.ts - // pages/search-explore-page/store/sagas.ts - // pages/search-explore-page/store/exploreCollections/sagas.ts - // store/solana/sagas.ts - // pages/trending-page/store/sagas.ts - // pages/trending-page/store/lineups/trending/sagas.ts - // pages/trending-underground-page/store/lineups/tracks/sagas.ts - // pages/trending-underground-page/store/sagas.ts - // pages/premium-tracks/sagas.ts - // pages/premium-tracks/lineups/tracks/sagas.ts - // pages/smart-collection/store/sagas.ts - // store/application/ui/theme/sagas.ts - // pages/search-page/store/sagas.ts - // pages/search-page/store/lineups/tracks/sagas.ts - // notifications/store/sagas.ts - // notifications/store/mobileSagas.ts - // pages/remixes-page/store/sagas.ts - // pages/remixes-page/store/lineups/tracks/sagas.ts - // - // pull in the following from web - // once the player and dependencies are migrated - // store/queue/sagas.ts }) diff --git a/packages/common/src/utils/challenges.ts b/packages/common/src/utils/challenges.ts index 44b562c05fd..6df422b2de7 100644 --- a/packages/common/src/utils/challenges.ts +++ b/packages/common/src/utils/challenges.ts @@ -442,17 +442,6 @@ export const isPlayCountChallenge = ( ) } -export const isAudioMatchingChallenge = ( - challenge: ChallengeRewardID -): challenge is - | ChallengeName.AudioMatchingSell - | ChallengeName.AudioMatchingBuy => { - return ( - challenge === ChallengeName.AudioMatchingSell || - challenge === ChallengeName.AudioMatchingBuy - ) -} - /** Returns true if the challenge is not a cooldown challenge by checking * whether it has `cooldown_days` defined and whether the challenge has been * created for more than `cooldown_days` days. diff --git a/packages/common/src/utils/commonPasswordCheck.ts b/packages/common/src/utils/commonPasswordCheck.ts index 65baab4d005..df108d8188e 100644 --- a/packages/common/src/utils/commonPasswordCheck.ts +++ b/packages/common/src/utils/commonPasswordCheck.ts @@ -1,4 +1,5 @@ -const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)) +const sleep = (ms: number) => + new Promise((resolve) => setTimeout(resolve, ms)) const HIBP_URL = 'https://api.pwnedpasswords.com/range/' @@ -24,8 +25,7 @@ export const commonPasswordCheck = async ( ]) if (result) { - // @ts-ignore - const text = (await result?.text()) as string + const text = await result.text() const hashArr = text.split(/\s+/g).map((s) => s.slice(0, s.indexOf(':'))) // If there is no match, return false diff --git a/packages/common/src/utils/contentTypeUtils.ts b/packages/common/src/utils/contentTypeUtils.ts index 8e8445dfeeb..0e09df13ea0 100644 --- a/packages/common/src/utils/contentTypeUtils.ts +++ b/packages/common/src/utils/contentTypeUtils.ts @@ -8,11 +8,6 @@ export const isContentPartialTrack = >( content?: Nullable> ): content is T => !!content && 'track_id' in content -/** Typeguard for determining if content is a Collection but can return as a subset of the Collection type */ -export const isContentPartialCollection = >( - content?: Nullable> -): content is T => !!content && 'playlist_id' in content - /** Typeguard for determiniing if content is a Track */ export const isContentTrack = ( content?: Nullable> diff --git a/packages/common/src/utils/formatTrackTimestamp.ts b/packages/common/src/utils/formatTrackTimestamp.ts deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/packages/common/src/utils/formatUtil.ts b/packages/common/src/utils/formatUtil.ts index da01390e575..c0162ea440a 100644 --- a/packages/common/src/utils/formatUtil.ts +++ b/packages/common/src/utils/formatUtil.ts @@ -92,10 +92,6 @@ export const formatNumberCommas = (num: number | string) => { ) } -export const trimRightZeros = (number: string) => { - return number.replace(/(\d)0+$/gm, '$1') -} - export const checkOnlyNumeric = (number: string) => { const reg = /^\d+$/ return reg.test(number) @@ -112,10 +108,6 @@ export const checkOnlyWeiFloat = (number: string) => { return true } -export const checkWeiNumber = (number: string) => { - return checkOnlyNumeric(number) || checkOnlyWeiFloat(number) -} - /** Capitalizes the given input string */ export const formatCapitalizeString = (word: string) => { const lowerCase = word.toLowerCase() @@ -184,12 +176,6 @@ export const getHash = (str: string) => }, 0) ).toString(36) -/** - * Formats a number to be a double digit - */ -export const formatDoubleDigit = (value: number) => - value.toString().padStart(2, '0') - /** * Formats a ticker to be uppercase and trimmed */ diff --git a/packages/common/src/utils/reducer.ts b/packages/common/src/utils/reducer.ts index 493442f3ea4..29534a30005 100644 --- a/packages/common/src/utils/reducer.ts +++ b/packages/common/src/utils/reducer.ts @@ -1,14 +1,5 @@ -// TODO(nkang): Note - this is copied from web/utils/reducer.ts. Uncomment the commented code if needed for the common store later on. - -// import { UseSelectorHook } from './selectorHook' -// import { useSelector as untypedUseSelector } from 'react-redux' import { Action } from 'redux' -/** - * Typed version of Redux useSelector - */ -// export const useSelector: UseSelectorHook = untypedUseSelector - /** * Handy util for generating a reducer function from an actionmap. * diff --git a/packages/common/src/utils/sagaHelpers.ts b/packages/common/src/utils/sagaHelpers.ts index 1b48b68d5c9..721dc6e4c9c 100644 --- a/packages/common/src/utils/sagaHelpers.ts +++ b/packages/common/src/utils/sagaHelpers.ts @@ -1,19 +1,9 @@ /** Helper Sagas */ import { QueryClient } from '@tanstack/react-query' -import { eventChannel, END, EventChannel } from 'redux-saga' -import { ActionPattern, GetContextEffect } from 'redux-saga/effects' -import { - all, - call, - delay, - getContext, - put, - select, - spawn, - take, - takeEvery -} from 'typed-redux-saga' +import { EventChannel } from 'redux-saga' +import { GetContextEffect } from 'redux-saga/effects' +import { call, getContext, put, select, take } from 'typed-redux-saga' import { Action } from 'typesafe-actions' // this import needs to be very specific for SSR bundlesize @@ -27,22 +17,6 @@ const messages = { somethingWrong: 'Something went wrong' } -/** - * Calls the provided array of calls in batches with delayMs milliseconds between each batch. - */ -export function* batchYield( - calls: Generator[], - batchSize: number, - delayMs: number -) { - let remainingCalls = calls - while (remainingCalls.length > 0) { - yield all(remainingCalls.slice(0, batchSize)) - remainingCalls = remainingCalls.slice(batchSize) - yield delay(delayMs) - } -} - /** * Takes a channel that yields the value of a Redux action, waits for it to yield and then * dispatches the action. @@ -57,14 +31,6 @@ export function* actionChannelDispatcher(channel: EventChannel) { } } -export function* channelCanceller( - channel: EventChannel>, - action: ActionPattern> -) { - yield take(action) - channel.close() -} - /** * Waits for the selector to return a truthy value. * @param {function} selector @@ -88,28 +54,6 @@ export function* waitForValue( return value } -function doEveryImpl(millis: number, times: number | null) { - return eventChannel((emitter) => { - // Emit once at the start - emitter(times || true) - - // Emit once every millis - const iv = setInterval(() => { - if (times !== null) { - times -= 1 - } - if (times === null || times > 0) { - emitter(times || true) - } else { - emitter(END) - } - }, millis) - return () => { - clearInterval(iv) - } - }) -} - /** * Waits for a query function to return a truthy value. * Similar to waitForValue but for tanstack query data. @@ -133,24 +77,6 @@ export function* waitForQueryValue( return value as TResult } -/** - * Repeatedly calls a saga/async function on an interval for up to a set number of times. - * @param {number} millis - * @param {function *} fn - * @param {number?} times - */ -export function* doEvery( - millis: number, - fn: (...args: any) => any, - times: number | null = null -) { - const chan: EventChannel = yield call(doEveryImpl, millis, times) - yield spawn(function* () { - yield takeEvery(chan, fn) - }) - return chan -} - /** * Waits for account to finish loading, whether it fails or succeeds. */ diff --git a/packages/common/src/utils/selectorHelpers.ts b/packages/common/src/utils/selectorHelpers.ts index 81dde8f7012..b10dc4927ed 100644 --- a/packages/common/src/utils/selectorHelpers.ts +++ b/packages/common/src/utils/selectorHelpers.ts @@ -1,23 +1,6 @@ import { isEqual } from 'lodash' import { createSelectorCreator, defaultMemoize } from 'reselect' -export const shallowCompare = (a: T, b: T) => - a && - b && - Object.keys(a).length === Object.keys(b).length && - Object.keys(a).every( - (key) => Object.prototype.hasOwnProperty.call(b, key) && a[key] === b[key] - ) - -export const areSetsEqual = (a: Set, b: Set) => - a.size === b.size && [...a].every((value) => b.has(value)) - -// A selector creator that memoizes based on a shallow object comparison. -export const createShallowSelector = createSelectorCreator( - defaultMemoize, - shallowCompare -) - export const createDeepEqualSelector = createSelectorCreator( defaultMemoize, isEqual diff --git a/packages/common/src/utils/socialLinks.ts b/packages/common/src/utils/socialLinks.ts index c87870958e0..7c0fc1e0686 100644 --- a/packages/common/src/utils/socialLinks.ts +++ b/packages/common/src/utils/socialLinks.ts @@ -104,10 +104,3 @@ export const getUserSocialLinks = (user?: UserSocialSource | null) => { return links.slice(0, 4) } - -export const socialLinksUtils = { - SOCIAL_BASE_URLS, - getUserSocialLinks, - sanitizeSocialHandle, - sanitizeWebsiteUrl -} diff --git a/packages/common/src/utils/stringUtils.ts b/packages/common/src/utils/stringUtils.ts index baea3534f20..2365ab86566 100644 --- a/packages/common/src/utils/stringUtils.ts +++ b/packages/common/src/utils/stringUtils.ts @@ -1,44 +1,5 @@ import { getTokenDecimalPlaces } from './decimal' -/** - * Converts a provided URL params object to a query string - */ -export const paramsToQueryString = (params: { - [key: string]: string | string[] -}) => { - if (!params) return '' - return Object.entries(params) - .filter((p) => p[1] !== undefined && p[1] !== null) - .map((p) => { - if (Array.isArray(p[1])) { - // Otherwise, join in the form of - // ?key=val1&key=val2&key=val3... - return p[1].map((val) => `${p[0]}=${encodeURIComponent(val)}`).join('&') - } - return `${p[0]}=${encodeURIComponent(p[1]!)}` - }) - .join('&') -} - -/** - * Track permalinks have the following format: '//' - */ -export const parseTrackRouteFromPermalink = (permalink: string) => { - const [, handle, slug] = permalink.split('/') - return { slug, trackId: null, handle } -} - -/** - * Playlist permalinks have the following format: '//playlist/' - * - * @param permalink - * @returns playlist id - */ -export const parsePlaylistIdFromPermalink = (permalink: string) => { - const playlistNameWithId = permalink?.split('/').slice(-1)[0] ?? '' - return parseInt(playlistNameWithId.split('-').slice(-1)[0]) -} - /** Takes a list of comma-separated strings, splits and parses them into numbers */ export const parseIntList = (str: string) => { return str.split(',').map((s) => Number.parseInt(s)) diff --git a/packages/common/src/utils/uid.ts b/packages/common/src/utils/uid.ts index de2dd4dacc1..a828164b650 100644 --- a/packages/common/src/utils/uid.ts +++ b/packages/common/src/utils/uid.ts @@ -66,39 +66,6 @@ export class Uid { } } -export function makeUids( - kinds: string[], - ids: (number | string)[], - source?: string -) { - if (Array.isArray(kinds)) { - // Multiple kinds in the ids array. - const totals: Record = {} - const counts: Record = {} - ids.forEach((id, i) => { - const key = `${kinds[i]}${id}` - if (key in totals) totals[key] += 1 - else totals[key] = 0 - counts[i] = totals[key] - }) - const uids = ids.map((id, i) => Uid.build(kinds[i], id, source, counts[i])) - return uids.map((uid) => uid.toString()) - } else { - // Single kind. - const kind = kinds - - const totals: Record = {} - const counts: Record = {} - ids.forEach((id, i) => { - if (id in totals) totals[id] += 1 - else totals[id] = 0 - counts[i] = totals[id] - }) - const uids = ids.map((id, i) => Uid.build(kind, id, source, counts[i])) - return uids.map((uid) => uid.toString()) - } -} - export function makeUid(kind: string, id: ID, source?: string) { const uid = Uid.build(kind, id, source) return uid.toString() @@ -132,12 +99,6 @@ export const makeKindId = (kind: string, id: ID | string | undefined) => */ export const getIdFromKindId = (kindId: string) => kindId.split('-')[1] -/** - * Gets the kind from a kind id - * @param kindId - */ -export const getKindFromKindId = (kindId: string) => kindId.split('-')[0] - /** * Gets the numeric id from a uid * @param uid diff --git a/packages/common/src/utils/urlUtils.ts b/packages/common/src/utils/urlUtils.ts index 0517cc54b30..98da161cec0 100644 --- a/packages/common/src/utils/urlUtils.ts +++ b/packages/common/src/utils/urlUtils.ts @@ -19,8 +19,6 @@ export const isInternalAudiusUrl = (url: string) => url.startsWith('/') || (isAudiusUrl(url) && !externalAudiusLinks.some((externalLink) => externalLink.includes(url))) -export const isExternalAudiusUrl = (url: string) => - new RegExp(audiusUrlRegex).test(url) export const getPathFromAudiusUrl = (url: string) => url.startsWith('/') ? url diff --git a/packages/harmony/src/components/button/FilterButton/FilterButtonKeyHandler.tsx b/packages/harmony/src/components/button/FilterButton/FilterButtonKeyHandler.tsx deleted file mode 100644 index b5aff789014..00000000000 --- a/packages/harmony/src/components/button/FilterButton/FilterButtonKeyHandler.tsx +++ /dev/null @@ -1,102 +0,0 @@ -import { RefObject, useState, ReactNode, useEffect } from 'react' - -import { FilterButtonOptionType } from './types' - -type FilterButtonKeyHandlerProps = { - children: (activeValue: Value | null) => ReactNode - disabled?: boolean - onChange: (value: Value) => void - optionRefs: RefObject - options: FilterButtonOptionType[] - scrollRef: RefObject -} - -/** - * Handles key events for the popup inside the FilterButton component - * - * Calls the `children` function with the currently active value - */ -export const FilterButtonKeyHandler = ( - props: FilterButtonKeyHandlerProps -) => { - const { disabled, options, onChange, optionRefs, scrollRef, children } = props - const [activeIndex, setActiveIndex] = useState(null) - const activeValue = activeIndex !== null ? options[activeIndex]?.value : null - - useEffect(() => { - const adjustScrollPosition = (newIndex: number | null) => { - if (newIndex !== null) { - if (optionRefs.current) { - optionRefs.current[newIndex].scrollIntoView({ - behavior: 'smooth', - block: 'start' - }) - } - } else { - scrollRef.current?.scrollTo({ top: 0, behavior: 'smooth' }) - } - } - - const handleKeyDown = (event: KeyboardEvent) => { - if (disabled) { - return - } - - switch (event.key) { - case 'ArrowUp': - event.stopPropagation() - event.preventDefault() - setActiveIndex((prevIndex) => { - const getNewIndex = () => { - if (prevIndex === null) { - return options.length - 1 - } - - return prevIndex > 0 ? prevIndex - 1 : null - } - - const newIndex = getNewIndex() - adjustScrollPosition(newIndex) - - return newIndex - }) - break - case 'ArrowDown': - event.stopPropagation() - event.preventDefault() - setActiveIndex((prevIndex) => { - const getNewIndex = () => { - if (prevIndex === null) { - return 0 - } - - return prevIndex < options.length - 1 ? prevIndex + 1 : null - } - - const newIndex = getNewIndex() - adjustScrollPosition(newIndex) - - return newIndex - }) - break - case 'Enter': - event.stopPropagation() - event.preventDefault() - if (activeIndex !== null && options[activeIndex]) { - onChange(options[activeIndex].value) - } - break - default: - break - } - } - - window.addEventListener('keydown', handleKeyDown) - - return () => { - window.removeEventListener('keydown', handleKeyDown) - } - }, [disabled, options, activeIndex, scrollRef, optionRefs, onChange]) - - return <>{children(activeValue)} -} diff --git a/packages/harmony/src/components/button/FollowButton/FollowButton.tsx b/packages/harmony/src/components/button/FollowButton/FollowButton.tsx index 9892298539d..ea6d1d203a5 100644 --- a/packages/harmony/src/components/button/FollowButton/FollowButton.tsx +++ b/packages/harmony/src/components/button/FollowButton/FollowButton.tsx @@ -88,8 +88,6 @@ export const FollowButton = forwardRef( setIsPressing(false) }, []) - useEffect(() => {}, [value]) - const handleClick = useCallback(() => { if (value) { onUnfollow?.() diff --git a/packages/harmony/src/components/modal/findAncestor.ts b/packages/harmony/src/components/modal/findAncestor.ts index 96cf61c8e94..e6a303cf3e1 100644 --- a/packages/harmony/src/components/modal/findAncestor.ts +++ b/packages/harmony/src/components/modal/findAncestor.ts @@ -1,17 +1,9 @@ /** - * Legacy browser support for `Element.closest` + * Finds the closest ancestor of `el` (including `el` itself) matching the + * given selector, or null if there is none. * @param el * @param selector query selector */ export const findAncestor = (el: Element | null, selector: string) => { - if (el !== null && el.closest) { - return el.closest(selector) - } - // Fall back to just looping back through parents - while ( - (el = el?.parentElement ?? null) && - // @ts-ignore - !(el.matches || el.matchesSelector).call(el, selector) - ); - return el + return el?.closest(selector) ?? null } diff --git a/packages/mobile/src/components/audio/AudioPlayer.tsx b/packages/mobile/src/components/audio/AudioPlayer.tsx index 32bc64d1a04..b246085fd52 100644 --- a/packages/mobile/src/components/audio/AudioPlayer.tsx +++ b/packages/mobile/src/components/audio/AudioPlayer.tsx @@ -59,6 +59,7 @@ import { import { useChromecast } from './GoogleCast' import { addTracksAroundCurrent } from './addTracksAroundCurrent' +import { RESTART_THRESHOLD_SEC, SKIP_DURATION_SEC } from './constants' import { isStreamSignatureFresh } from './streamSignature' import { useSavePodcastProgress } from './useSavePodcastProgress' @@ -98,9 +99,6 @@ const { const { getIsReachable } = reachabilitySelectors const { getNftAccessSignatureMap } = gatedContentSelectors -// TODO: These constants are the same in now playing drawer. Move them to shared location -const SKIP_DURATION_SEC = 15 -const RESTART_THRESHOLD_SEC = 3 const RECORD_LISTEN_SECONDS = 1 const TRACK_END_BUFFER = 2 diff --git a/packages/mobile/src/components/audio/constants.ts b/packages/mobile/src/components/audio/constants.ts new file mode 100644 index 00000000000..a0847618509 --- /dev/null +++ b/packages/mobile/src/components/audio/constants.ts @@ -0,0 +1,8 @@ +/** How far the jump forward / backward controls seek, in seconds */ +export const SKIP_DURATION_SEC = 15 + +/** + * If the current position is past this many seconds, "previous" restarts the + * current track instead of going to the previous one + */ +export const RESTART_THRESHOLD_SEC = 3 diff --git a/packages/mobile/src/components/comments/CommentActionBar.tsx b/packages/mobile/src/components/comments/CommentActionBar.tsx index 4f87a26b0b0..a8a75345495 100644 --- a/packages/mobile/src/components/comments/CommentActionBar.tsx +++ b/packages/mobile/src/components/comments/CommentActionBar.tsx @@ -24,7 +24,7 @@ export const CommentActionBar = (props: CommentActionBarProps) => { const { isCurrentUserReacted, reactCount, id: commentId } = comment const [reactToComment] = useReactToComment() - const [reactionState, setReactionState] = useState(isCurrentUserReacted) // TODO: need to pull starting value from metadata + const [reactionState, setReactionState] = useState(isCurrentUserReacted) const { setReplyingAndEditingState } = useCurrentCommentSection() const handleCommentReact = useCallback(() => { diff --git a/packages/mobile/src/components/contest-card/ContestCard.tsx b/packages/mobile/src/components/contest-card/ContestCard.tsx index c524cd46864..4c1f9eb869d 100644 --- a/packages/mobile/src/components/contest-card/ContestCard.tsx +++ b/packages/mobile/src/components/contest-card/ContestCard.tsx @@ -282,7 +282,7 @@ export const ContestCard = (props: ContestCardProps) => { } // Skip contests hosted by deactivated users — same filter as the web - // ContestCard. The discovery endpoint can still surface tombstoned + // ContestCard. The validator node API can still surface tombstoned // hosts (the fake "Audius" / life-audius-airdrop accounts) and // rendering them on explore was the QA bug we needed to suppress. if (user.is_deactivated) { diff --git a/packages/mobile/src/components/now-playing-drawer/NowPlayingDrawer.tsx b/packages/mobile/src/components/now-playing-drawer/NowPlayingDrawer.tsx index 6ff64b6d4aa..9cc86719015 100644 --- a/packages/mobile/src/components/now-playing-drawer/NowPlayingDrawer.tsx +++ b/packages/mobile/src/components/now-playing-drawer/NowPlayingDrawer.tsx @@ -36,6 +36,10 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context' import TrackPlayer from 'react-native-track-player' import { useDispatch, useSelector } from 'react-redux' +import { + RESTART_THRESHOLD_SEC, + SKIP_DURATION_SEC +} from 'app/components/audio/constants' import { BOTTOM_BAR_HEIGHT, COLLAPSE_DROP_START, @@ -75,8 +79,6 @@ const { seekTo: seek, reset, next, previous } = playbackActions const { getPlaying, getTrackId, getCounter, getBuffering } = playbackSelectors const STATUS_BAR_FADE_CUTOFF = 0.6 -const SKIP_DURATION_SEC = 15 -const RESTART_THRESHOLD_SEC = 3 // If the top screen inset is greater than this, // the status bar will be hidden when the drawer is open diff --git a/packages/mobile/src/haptics.ts b/packages/mobile/src/haptics.ts index 23bc3a50b16..f3ffdfa9f6a 100644 --- a/packages/mobile/src/haptics.ts +++ b/packages/mobile/src/haptics.ts @@ -8,7 +8,6 @@ const options = { export const light = () => { if (Platform.OS === 'android') { - // @ts-ignore ReactNativeHapticFeedback.trigger('keyboardPress', options) } else { ReactNativeHapticFeedback.trigger('impactLight', options) @@ -18,7 +17,6 @@ export const light = () => { export const medium = () => { if (Platform.OS === 'android') { // This should be updated to match ios impactMedium - // @ts-ignore ReactNativeHapticFeedback.trigger('keyboardPress', options) } else { ReactNativeHapticFeedback.trigger('impactMedium', options) diff --git a/packages/mobile/src/notifications.ts b/packages/mobile/src/notifications.ts index 1ca54ee4de2..cce06661294 100644 --- a/packages/mobile/src/notifications.ts +++ b/packages/mobile/src/notifications.ts @@ -80,7 +80,7 @@ type Token = { type NotificationNavigation = { navigate: (notification: any) => void } -/** First-party Discovery campaign open — mobile remote push opens only. */ +/** Reports a first-party campaign open to the API — mobile remote push opens only. */ async function reportNotificationCampaignPushOpen( campaignId: string ): Promise { diff --git a/packages/mobile/src/screens/app-screen/AppTabScreen.tsx b/packages/mobile/src/screens/app-screen/AppTabScreen.tsx index 68fb5a4d0cd..ddb0489aa39 100644 --- a/packages/mobile/src/screens/app-screen/AppTabScreen.tsx +++ b/packages/mobile/src/screens/app-screen/AppTabScreen.tsx @@ -444,10 +444,7 @@ export const AppTabScreen = ({ baseScreen, Stack }: AppTabScreenProps) => { ChatScreen} - getId={({ params }) => - // @ts-ignore hard to correctly type navigation params (PAY-1141) - params?.chatId - } + getId={({ params }) => params?.chatId} options={{ ...screenOptions, fullScreenGestureEnabled: false }} /> { values.title || messages.untitled } - // @ts-ignore filePath={selectedTrackFile || streamUrl || ''} trackId={values.track_id} isUpload={isUpload} diff --git a/packages/mobile/src/screens/external-wallets/components/SolanaPhoneOption.tsx b/packages/mobile/src/screens/external-wallets/components/SolanaPhoneOption.tsx index 586f786d522..317787f2e00 100644 --- a/packages/mobile/src/screens/external-wallets/components/SolanaPhoneOption.tsx +++ b/packages/mobile/src/screens/external-wallets/components/SolanaPhoneOption.tsx @@ -54,7 +54,6 @@ export const SolanaPhoneOption = () => { let publicKey: string const { - // @ts-ignore: wallet adapter types are wrong signed_payloads: [signature] } = await transact(async (wallet) => { const freshAccount = await authorizeSession(wallet) diff --git a/packages/mobile/src/screens/form-screen/FormScreen.tsx b/packages/mobile/src/screens/form-screen/FormScreen.tsx index 258b1884528..45eaf9a3501 100644 --- a/packages/mobile/src/screens/form-screen/FormScreen.tsx +++ b/packages/mobile/src/screens/form-screen/FormScreen.tsx @@ -64,7 +64,6 @@ export const FormScreen = (props: FormScreenProps) => { backgroundColor='white' borderTop='default' gap='m' - // style={css({ position: 'absolute', bottom: 0, left: 0, right: 0 })} > {bottomSection ?? ( <> diff --git a/packages/mobile/src/screens/profile-screen/ProfileHeader/ProfileSocials.tsx b/packages/mobile/src/screens/profile-screen/ProfileHeader/ProfileSocials.tsx index 16a81271687..7b4a072d3d5 100644 --- a/packages/mobile/src/screens/profile-screen/ProfileHeader/ProfileSocials.tsx +++ b/packages/mobile/src/screens/profile-screen/ProfileHeader/ProfileSocials.tsx @@ -64,7 +64,6 @@ export const ProfileSocials = () => { const styles = useStyles() const { tier } = useTierAndVerifiedForUser(user_id) - // const tier = 'none' // Need to start opacity at 1 so skeleton is visible. const opacity = useRef(new Animated.Value(1)).current diff --git a/packages/mobile/src/screens/settings-screen/SettingsRow.tsx b/packages/mobile/src/screens/settings-screen/SettingsRow.tsx index 636238727ed..46cec0176c9 100644 --- a/packages/mobile/src/screens/settings-screen/SettingsRow.tsx +++ b/packages/mobile/src/screens/settings-screen/SettingsRow.tsx @@ -48,7 +48,6 @@ export const SettingsRow = (props: SettingsRowProps) => { return ( - {/* @ts-ignore */} {children} {onPress || url ? ( diff --git a/packages/mobile/src/store/cache/collections/createPlaylistRequestedSaga.ts b/packages/mobile/src/store/cache/collections/createPlaylistRequestedSaga.ts index 3ec45f642e6..fd798bc0b3b 100644 --- a/packages/mobile/src/store/cache/collections/createPlaylistRequestedSaga.ts +++ b/packages/mobile/src/store/cache/collections/createPlaylistRequestedSaga.ts @@ -34,7 +34,6 @@ export function* createPlaylistRequestedSaga() { } case 'route': { if (navigationRef.isReady()) { - // @ts-ignore navigationRef is not parametrized correctly (PAY-1141) navigationRef.navigate('Collection', { id: playlistId }) } break diff --git a/packages/mobile/src/store/chat/sagas.ts b/packages/mobile/src/store/chat/sagas.ts index 724a6f8a965..b3bb542e586 100644 --- a/packages/mobile/src/store/chat/sagas.ts +++ b/packages/mobile/src/store/chat/sagas.ts @@ -20,7 +20,6 @@ function* watchGoToChat() { StackActions.replace('Chat', { chatId, presetMessage }) ) } else { - // @ts-ignore navigationRef is not parametrized correctly (PAY-1141) navigationRef.navigate('Chat', { chatId, presetMessage }) } } diff --git a/packages/mobile/src/utils/theme.ts b/packages/mobile/src/utils/theme.ts index b95c1ed3759..c5f646e8192 100644 --- a/packages/mobile/src/utils/theme.ts +++ b/packages/mobile/src/utils/theme.ts @@ -286,9 +286,7 @@ export const useTheme = (baseStyles: object, toTheme: object) => { const newStyles = {} Object.keys(toTheme).forEach((key) => { - // @ts-ignore if (toTheme[key] in themeStyles) { - // @ts-ignore newStyles[key] = themeStyles[toTheme[key]] } }) diff --git a/packages/sdk/src/sdk/api/challenges/types.ts b/packages/sdk/src/sdk/api/challenges/types.ts index bd9d2de1b8b..e8153a0c0b9 100644 --- a/packages/sdk/src/sdk/api/challenges/types.ts +++ b/packages/sdk/src/sdk/api/challenges/types.ts @@ -1,4 +1,3 @@ -// TODO: Not sure if still needed export enum ChallengeId { TRACK_UPLOADS = 'u', REFERRALS = 'r', diff --git a/packages/sdk/src/sdk/services/AntiAbuseOracle/types.ts b/packages/sdk/src/sdk/services/AntiAbuseOracle/types.ts index ff0252f5477..25e0c5b194d 100644 --- a/packages/sdk/src/sdk/services/AntiAbuseOracle/types.ts +++ b/packages/sdk/src/sdk/services/AntiAbuseOracle/types.ts @@ -1,8 +1,5 @@ import { z } from 'zod' -// @ts-ignore:next-line ignore the unused import, used in jsdoc -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import type { ChallengesApi } from '../../api/challenges/ChallengesApi' import { ChallengeId } from '../../api/challenges/types' import { AntiAbuseOracleSelectorService } from '../AntiAbuseOracleSelector' @@ -11,11 +8,7 @@ export const GetAttestationSchema = z.object({ handle: z.string(), /** The challenge identifier. As in, the challenge "name." */ challengeId: z.nativeEnum(ChallengeId), - /** - * Identifier for the completed challenge instance. - * - * @see {@link ChallengesApi.generateSpecifier} - */ + /** Identifier for the completed challenge instance. */ specifier: z.string(), /** The amount being claimed, in decimal wAUDIO. */ amount: z.number() @@ -33,13 +26,13 @@ export type AttestationResponse = { export type AntiAbuseOracleHealthCheckResponse = { /** The version number of AAO deployed. */ version: number - /** The discovery node endpoint the AAO is using. */ + /** The validator node endpoint the AAO is using. */ selectedDiscoveryNode: string /** A list of other AAO endpoints. (note: Empty at time of writing!) */ otherAntiAbuseOracleEndpoints: string[] /** The wallet public key address for this AAO. */ walletPubkey: string - /** The wallet public key address for this AAO from a discovery node plugin. */ + /** The wallet public key address for this AAO from a validator node plugin. */ antiAbuseWalletPubkey?: string /** Whether the database container is healthy (UP) or unhealthy (DOWN). */ db: 'UP' | 'DOWN' diff --git a/packages/sdk/src/sdk/services/EntityManager/EntityManagerClient.ts b/packages/sdk/src/sdk/services/EntityManager/EntityManagerClient.ts index 112efab0446..a2eed6743e4 100644 --- a/packages/sdk/src/sdk/services/EntityManager/EntityManagerClient.ts +++ b/packages/sdk/src/sdk/services/EntityManager/EntityManagerClient.ts @@ -11,6 +11,7 @@ import { productionConfig } from '../../config/production' import fetch, { Headers } from '../../utils/fetch' import { mergeConfigWithDefaults } from '../../utils/mergeConfigs' import { getNonce } from '../../utils/nonce' +import { wait } from '../../utils/wait' import type { AudiusWalletClient } from '../AudiusWalletClient' import type { LoggerService } from '../Logger' @@ -201,9 +202,7 @@ export class EntityManagerClient implements EntityManagerService { `Could not confirm write within ${confirmationTimeout}ms` ) } - await new Promise((resolve) => - setTimeout(resolve, confirmationPollingInterval) - ) + await wait(confirmationPollingInterval) confirmation = await confirmBlock() } diff --git a/packages/sdk/src/sdk/services/Solana/SolanaRelay.ts b/packages/sdk/src/sdk/services/Solana/SolanaRelay.ts index f32b3d4a8f8..2f894ae2412 100644 --- a/packages/sdk/src/sdk/services/Solana/SolanaRelay.ts +++ b/packages/sdk/src/sdk/services/Solana/SolanaRelay.ts @@ -25,17 +25,17 @@ import { } from './types' /** - * Client for the Solana Relay Plugin on Discovery. + * Client for the Solana Relay Plugin on validator nodes. */ export class SolanaRelay extends BaseAPI { /** * Public key of the currently selected transaction fee payer - * from the selected Discovery Node. + * from the selected validator node. */ private feePayer: PublicKey | null = null /** - * Gets a random fee payer public key from the selected discovery node's + * Gets a random fee payer public key from the selected validator node's * Solana relay plugin. * * Used when relay transactions don't specify a fee payer override. @@ -110,7 +110,7 @@ export class SolanaRelay extends BaseAPI { } /** - * Relays a transaction to the selected discovery node's Solana relay plugin. + * Relays a transaction to the selected validator node's Solana relay plugin. */ public async relay( params: RelayRequest, @@ -286,7 +286,7 @@ export class SolanaRelay extends BaseAPI { const noTokenInput = !tokenOutputAmount if (noAudioInput && noTokenInput) { throw new Error( - 'Invalid arguments. Either solInputAmount or tokenOutputAmount must be provided' + 'Invalid arguments. Either audioInputAmount or tokenOutputAmount must be provided' ) } diff --git a/packages/sdk/src/sdk/services/Solana/SolanaRelayWalletAdapter.ts b/packages/sdk/src/sdk/services/Solana/SolanaRelayWalletAdapter.ts index 3a5f5e1dbc3..08211fd64b9 100644 --- a/packages/sdk/src/sdk/services/Solana/SolanaRelayWalletAdapter.ts +++ b/packages/sdk/src/sdk/services/Solana/SolanaRelayWalletAdapter.ts @@ -11,7 +11,7 @@ import type { SolanaRelay } from './SolanaRelay' import type { SolanaWalletAdapter } from './types' /** - * Wallet adapter that uses the Solana Relay Plugin on Discovery Node. + * Wallet adapter that uses the Solana Relay Plugin on validator nodes. * * Implementing this interface allows consumers to choose to pay for their own * transactions rather than using our relay, simply by using their own wallet @@ -58,7 +58,7 @@ export class SolanaRelayWalletAdapter implements SolanaWalletAdapter { } /** - * On connection, grabs the fee payer from the Discovery Node plugin. + * On connection, grabs the fee payer from the validator node's relay plugin. */ public async connect() { this._connecting = true @@ -78,7 +78,7 @@ export class SolanaRelayWalletAdapter implements SolanaWalletAdapter { } /** - * Sends a transaction using the relay to Discovery Node. + * Sends a transaction using the relay on a validator node. * @param transaction the transaction to send. */ public async sendTransaction( diff --git a/packages/sdk/src/sdk/services/Solana/programs/RewardManagerClient/RewardManagerClient.ts b/packages/sdk/src/sdk/services/Solana/programs/RewardManagerClient/RewardManagerClient.ts index bfd9e3ce241..3a9430ca301 100644 --- a/packages/sdk/src/sdk/services/Solana/programs/RewardManagerClient/RewardManagerClient.ts +++ b/packages/sdk/src/sdk/services/Solana/programs/RewardManagerClient/RewardManagerClient.ts @@ -65,7 +65,7 @@ export class RewardManagerError extends Error { * Connected client to the Solana RewardManager program. * * The RewardManager program is in charge of disbursing the community awards - * based on attestations from N uniquely owned discovery nodes and an anti abuse + * based on attestations from N uniquely owned validator nodes and an anti abuse * oracle node. */ export class RewardManagerClient { diff --git a/packages/sdk/src/sdk/services/Storage/Storage.ts b/packages/sdk/src/sdk/services/Storage/Storage.ts index dcbdd661940..09de268756c 100644 --- a/packages/sdk/src/sdk/services/Storage/Storage.ts +++ b/packages/sdk/src/sdk/services/Storage/Storage.ts @@ -194,14 +194,14 @@ export class Storage implements StorageService { secondOffset: number userId: number }) { - const contentNodeEndpoint = await this.storageNodeSelector.getSelectedNode() + const storageNodeEndpoint = await this.storageNodeSelector.getSelectedNode() - if (!contentNodeEndpoint) { - throw new Error('No content node available') + if (!storageNodeEndpoint) { + throw new Error('No validator node available') } const url = new URL( - `${contentNodeEndpoint}/generate_preview/${cid}/${secondOffset}` + `${storageNodeEndpoint}/generate_preview/${cid}/${secondOffset}` ) url.searchParams.set('userId', String(userId)) diff --git a/packages/sdk/src/sdk/services/StorageNodeSelector/StorageNodeSelector.ts b/packages/sdk/src/sdk/services/StorageNodeSelector/StorageNodeSelector.ts index d8ee51fa370..9e340e1496d 100644 --- a/packages/sdk/src/sdk/services/StorageNodeSelector/StorageNodeSelector.ts +++ b/packages/sdk/src/sdk/services/StorageNodeSelector/StorageNodeSelector.ts @@ -4,7 +4,7 @@ import { RendezvousHash } from '../../utils/rendezvous' import type { LoggerService } from '../Logger' import { getDefaultStorageNodeSelectorConfig } from './getDefaultConfig' -import { isNodeHealthy } from './getNStorageNodes' +import { isNodeHealthy } from './isNodeHealthy' import type { HealthCheckResponseData, StorageNode, diff --git a/packages/sdk/src/sdk/services/StorageNodeSelector/getNStorageNodes.ts b/packages/sdk/src/sdk/services/StorageNodeSelector/getNStorageNodes.ts deleted file mode 100644 index bfb08f9f85b..00000000000 --- a/packages/sdk/src/sdk/services/StorageNodeSelector/getNStorageNodes.ts +++ /dev/null @@ -1,96 +0,0 @@ -import axios from 'axios' - -import { RendezvousHash } from '../../utils/rendezvous' - -export type StorageNode = { - owner: any - endpoint: string - spID: number - type: string - blockNumber: number - delegateOwnerWallet: string -} - -/** - * Selects numNodes storage nodes from the given list of allNodes, optionally ordering them (descending) by rendezvous score. - * @dev This makes the wallet lowercase - not suitable for use with CIDs because they're case sensitive (use RendezvousHash directly instead). - */ -export const getNStorageNodes = async ( - allNodes: StorageNode[], - numNodes = 0, - wallet = '', - logger = console -): Promise => { - try { - if (numNodes === 0) numNodes = allNodes.length - let sortedEndpoints: string[] - - // Sort endpoints by rendezvous score if a rendezvous key is provided - if (wallet?.length) { - const endpoints = allNodes.map((n) => n.endpoint.toLowerCase()) - const hash = new RendezvousHash(...endpoints) - sortedEndpoints = hash.getN(endpoints.length, wallet.toLowerCase()) - } else { - sortedEndpoints = allNodes.map((n) => n.endpoint) - } - - // Check multiple nodes at a time for health until we have numNodes healthy nodes - const healthyEndpoints: string[] = [] - for (let i = 0; i < sortedEndpoints.length; i += numNodes) { - const batch = sortedEndpoints.slice(i, i + numNodes) - const healthCheckPromises = batch.map( - async (endpoint) => await isNodeHealthy(endpoint, logger) - ) - const healthCheckResults = await Promise.all(healthCheckPromises) - - for (let j = 0; j < healthCheckResults.length; j++) { - if (healthCheckResults[j]) { - healthyEndpoints.push(batch[j]!) - } - } - - if (healthyEndpoints.length >= numNodes) { - return healthyEndpoints.slice(0, numNodes) - } - } - - if (numNodes !== allNodes.length && sortedEndpoints.length < numNodes) { - logger.error( - `getNStorageNodes: Could not select ${numNodes} healthy nodes from ${allNodes.length} nodes` - ) - } - - return healthyEndpoints - } catch (e) { - logger.error(`getNStorageNodes: Error selecting nodes: ${e}`) - return [] - } -} - -export const isNodeHealthy = async (endpoint: string, logger = console) => { - try { - const resp = await axios({ - baseURL: endpoint, - url: `/health_check`, - method: 'get', - timeout: 10_000 - }) - if (resp.status !== 200) { - logger.warn( - `isNodeHealthy: ${endpoint} returned non-200 status ${resp.status}` - ) - return false - } - - // check has space + not slow - const health = resp.data.data - - // skip nodes if avg transcode time is over 3 minutes - const avgTranscodeTime = health.transcodeStats?.AvgTranscodeTime || 0 - const isSlowTranscode = avgTranscodeTime > 180 - return health.diskHasSpace && !isSlowTranscode - } catch (e) { - logger.error(`isNodeHealthy: Error checking health: ${e}`) - return false - } -} diff --git a/packages/sdk/src/sdk/services/StorageNodeSelector/isNodeHealthy.ts b/packages/sdk/src/sdk/services/StorageNodeSelector/isNodeHealthy.ts new file mode 100644 index 00000000000..47d936f1561 --- /dev/null +++ b/packages/sdk/src/sdk/services/StorageNodeSelector/isNodeHealthy.ts @@ -0,0 +1,34 @@ +import axios from 'axios' + +import type { LoggerService } from '../Logger' + +export const isNodeHealthy = async ( + endpoint: string, + logger: Pick = console +) => { + try { + const resp = await axios({ + baseURL: endpoint, + url: `/health_check`, + method: 'get', + timeout: 10_000 + }) + if (resp.status !== 200) { + logger.warn( + `isNodeHealthy: ${endpoint} returned non-200 status ${resp.status}` + ) + return false + } + + // check has space + not slow + const health = resp.data.data + + // skip nodes if avg transcode time is over 3 minutes + const avgTranscodeTime = health.transcodeStats?.AvgTranscodeTime || 0 + const isSlowTranscode = avgTranscodeTime > 180 + return health.diskHasSpace && !isSlowTranscode + } catch (e) { + logger.error(`isNodeHealthy: Error checking health: ${e}`) + return false + } +} diff --git a/packages/sdk/src/sdk/utils/deepPartial.ts b/packages/sdk/src/sdk/utils/deepPartial.ts deleted file mode 100644 index fa6a5990e5e..00000000000 --- a/packages/sdk/src/sdk/utils/deepPartial.ts +++ /dev/null @@ -1,10 +0,0 @@ -// Adjusted from Terry: https://stackoverflow.com/questions/61132262/typescript-deep-partial -export type DeepPartial = T extends any[] - ? T - : T extends Set - ? T - : T extends object - ? { - [P in keyof T]?: DeepPartial - } - : T diff --git a/packages/sdk/src/sdk/utils/localStorage.ts b/packages/sdk/src/sdk/utils/localStorage.ts deleted file mode 100644 index 38e506caacd..00000000000 --- a/packages/sdk/src/sdk/utils/localStorage.ts +++ /dev/null @@ -1,19 +0,0 @@ -export type LocalStorage = { - getItem: (key: string) => Promise | string | null - setItem: (key: string, value: string) => Promise | void - removeItem: (key: string) => Promise | void -} - -/** - * Fallback for localStorage that works in node and the browser - * @returns localStorage - */ -export const getPlatformLocalStorage = async (): Promise => { - if (typeof window === 'undefined' || window === null) { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const LocalStorage = (await import('node-localstorage')).LocalStorage - return new LocalStorage('./local-storage') - } else { - return window.localStorage - } -} diff --git a/packages/sdk/src/sdk/utils/object.ts b/packages/sdk/src/sdk/utils/object.ts deleted file mode 100644 index d5471ad9d37..00000000000 --- a/packages/sdk/src/sdk/utils/object.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Return properties from a list for which the object is missing values - */ -export const objectMissingValues = ( - object: Record, - properties: string[] -) => { - return properties.filter((p) => object[p] === undefined || object[p] === null) -} diff --git a/packages/sdk/src/sdk/utils/uuid.ts b/packages/sdk/src/sdk/utils/uuid.ts deleted file mode 100644 index 9b95c9bcfcd..00000000000 --- a/packages/sdk/src/sdk/utils/uuid.ts +++ /dev/null @@ -1,20 +0,0 @@ -export const uuid = () => { - // https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript/873856#873856 - const s = [] - const hexDigits = '0123456789abcdef' - // all the ts-ignores are needed so the mobile package types things correctly - // remove when upgrading to latest typescript - for (let i = 0; i < 36; i++) { - // @ts-ignore - s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1) - } - // @ts-ignore - s[14] = '4' // bits 12-15 of the time_hi_and_version field to 0010 - // @ts-ignore - s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1) // bits 6-7 of the clock_seq_hi_and_reserved to 01 - // @ts-ignore - s[8] = s[13] = s[18] = s[23] = '-' - - const uuid = s.join('') - return uuid -} diff --git a/packages/web/src/common/store/pages/signon/sagas.ts b/packages/web/src/common/store/pages/signon/sagas.ts index 83012b50249..4fcf28d1877 100644 --- a/packages/web/src/common/store/pages/signon/sagas.ts +++ b/packages/web/src/common/store/pages/signon/sagas.ts @@ -522,7 +522,7 @@ function* signUp() { ) // Optimistically update localStorage so getLocalAccount returns - // complete user data before discovery provider has indexed. + // complete user data before the validator node has indexed. const updatedUser = { ...account.user, handle, diff --git a/packages/web/src/hooks/README.md b/packages/web/src/hooks/README.md index 8c87a19d9fb..ff33e7023a2 100644 --- a/packages/web/src/hooks/README.md +++ b/packages/web/src/hooks/README.md @@ -7,13 +7,9 @@ Each individual file should have more extensive documentation & examples. ## Hooks -### `useModalState` - -Allows for `useState` style ergonomics for getting & setting modal visibility. - ### `useNavigateToPage` -Wraps `redux-first-history` navigation in a single function. +Wraps react-router's `useNavigate` in a single function. ### `useInstanceVar` @@ -23,14 +19,6 @@ Convenience wrapper around useRef. Allows `useState`-like ergonomics. Wraps `classnames` with mobile switching logic to conditionally add mobile classes. -### `useHotkeys` - -Easily create mappings from keycodes to callbacks. - -### `useTabs` - -Creates tabs. - ### `usePortal` Portals a node out of its place in the dom hierarchy. @@ -38,7 +26,3 @@ Portals a node out of its place in the dom hierarchy. ### `useHasChangedRoute` Wraps the react router `useLocation` hook to allow a function to be called on route changes - -### `useScript` - -Loads a script in the DOM given a source url diff --git a/packages/web/src/hooks/useScript.ts b/packages/web/src/hooks/useScript.ts deleted file mode 100644 index 7878a2fe637..00000000000 --- a/packages/web/src/hooks/useScript.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { useEffect, useState } from 'react' - -export const useScript = (src: string, isModule = false) => { - const [scriptLoaded, setScriptLoaded] = useState(false) - - useEffect(() => { - const alreadyLoaded = [...document.getElementsByTagName('script')].find( - (script) => script.src === src - ) - if (alreadyLoaded) { - setScriptLoaded(true) - } else { - const script = document.createElement('script') - script.src = src - script.async = true - if (isModule) { - script.type = 'module' - } - script.onload = () => setScriptLoaded(true) - document.body.appendChild(script) - } - }, [src, isModule]) - - return scriptLoaded -} diff --git a/packages/web/src/pages/dev-tools/messages.ts b/packages/web/src/pages/dev-tools/messages.ts index 45524afa157..3ee820c34eb 100644 --- a/packages/web/src/pages/dev-tools/messages.ts +++ b/packages/web/src/pages/dev-tools/messages.ts @@ -37,7 +37,7 @@ export const messages = { aaoButton: 'Open AAO UI', healthzTitle: 'Health Monitor (Healthz)', healthzDescription: - 'Access the health monitoring dashboard for Audius network services including discovery nodes, content nodes, and other protocol infrastructure.', + 'Access the health monitoring dashboard for Audius network services including Open Audio validator nodes and other protocol infrastructure.', healthzButton: 'Open Healthz Dashboard', userIdParserTitle: 'User ID Parser', userIdParserDescription: