Skip to content

Commit 45279fe

Browse files
authored
[C-2969] Fix related artist images not loading (#3905)
1 parent f51e6ac commit 45279fe

File tree

6 files changed

+17
-7
lines changed

6 files changed

+17
-7
lines changed

packages/common/src/audius-query/createApi.ts

+9
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import { Dispatch } from 'redux'
1010
import { ErrorLevel } from 'models/ErrorReporting'
1111
import { Kind } from 'models/Kind'
1212
import { Status } from 'models/Status'
13+
import { UserMetadata } from 'models/User'
1314
import { getCollection } from 'store/cache/collections/selectors'
1415
import { getTrack } from 'store/cache/tracks/selectors'
16+
import { reformatUser } from 'store/cache/users/utils'
1517
import { CommonState } from 'store/reducers'
1618
import { getErrorMessage } from 'utils/error'
1719
import { Nullable, removeNullable } from 'utils/typeUtils'
@@ -252,6 +254,7 @@ const fetchData = async <Args, Data>(
252254
context: AudiusQueryContextType,
253255
dispatch: Dispatch
254256
) => {
257+
const { audiusBackend } = context
255258
try {
256259
dispatch(
257260
// @ts-ignore
@@ -274,6 +277,12 @@ const fetchData = async <Args, Data>(
274277
apiResponseSchema
275278
)
276279
data = result
280+
281+
// Format entities before adding to cache
282+
entities[Kind.USERS] = mapValues(
283+
entities[Kind.USERS] ?? [],
284+
(user: UserMetadata) => reformatUser(user, audiusBackend)
285+
)
277286
dispatch(addEntries(Object.keys(entities), entities))
278287
} else {
279288
data = apiData

packages/common/src/hooks/chats/useCanSendMessage.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { useSelector } from 'react-redux'
22

3+
import { useProxySelector } from 'hooks/useProxySelector'
34
import { User } from 'models/User'
45
import { ChatPermissionAction, CommonState } from 'store/index'
56
import {
67
getCanSendMessage,
78
getOtherChatUsers
89
} from 'store/pages/chat/selectors'
910

10-
import { useProxySelector } from '..'
11-
1211
/**
1312
* Returns whether or not the current user can send messages to the current chat
1413
*/

packages/common/src/store/cache/users/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { put } from 'typed-redux-saga'
33
import { Kind } from 'models/Kind'
44
import { UserMetadata } from 'models/User'
55
import { AudiusBackend } from 'services/audius-backend'
6-
import { cacheActions } from 'store/cache'
6+
import * as cacheActions from 'store/cache/actions'
77
import { getContext } from 'store/effects'
8-
import { makeUid } from 'utils'
98
import { waitForRead } from 'utils/sagaHelpers'
9+
import { makeUid } from 'utils/uid'
1010

1111
export function* processAndCacheUsers(users: UserMetadata[]) {
1212
yield* waitForRead()

packages/common/src/store/pages/chat/sagas.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@ import { Name } from 'models/Analytics'
1919
import { ErrorLevel } from 'models/ErrorReporting'
2020
import { ID } from 'models/Identifiers'
2121
import { Status } from 'models/Status'
22+
import * as toastActions from 'src/store/ui/toast/slice'
2223
import { getAccountUser, getUserId } from 'store/account/selectors'
23-
import { makeChatId, toastActions } from 'store/index'
2424

2525
import { decodeHashId, encodeHashId, removeNullable } from '../../../utils'
2626
import { cacheUsersActions } from '../../cache'
2727
import { getContext } from '../../effects'
2828

2929
import * as chatSelectors from './selectors'
3030
import { actions as chatActions } from './slice'
31+
import { makeChatId } from './utils'
3132

3233
// Attach ulid to window object for debugging DMs
3334
// @ts-ignore

packages/common/src/store/reachability/sagas.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { takeEvery, select, all, take } from 'typed-redux-saga'
22

3-
import { getContext } from 'store/commonStore'
3+
import { getContext } from 'store/effects'
44

55
import * as reachabilityActions from './actions'
66
import * as reachabilitySelectors from './selectors'

packages/common/src/store/ui/search-users-modal/sagas.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { accountSelectors } from 'store/account'
55
import { processAndCacheUsers } from 'store/cache/users/utils'
66
import { getContext } from 'store/effects'
77
import { SearchKind } from 'store/pages/search-results/types'
8-
import { searchUsersModalActions, searchUsersModalSelectors } from 'store/ui'
8+
import * as searchUsersModalSelectors from 'store/ui/search-users-modal/selectors'
9+
import { actions as searchUsersModalActions } from 'store/ui/search-users-modal/slice'
910

1011
const { getUserId } = accountSelectors
1112
const { searchUsers, searchUsersSucceeded } = searchUsersModalActions

0 commit comments

Comments
 (0)