Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ export const AccountsManagingYouHomePage = (
const { toast } = useContext(ToastContext)

const [removeManager, removeResult] = useRemoveManager()
const { data: managers, status: managersStatus } = useGetManagers({ userId })
// Always update manager list when mounting this page
const { data: managers, status: managersStatus } = useGetManagers(
{ userId },
{ force: true }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't know about this option, cool

)
// Don't flash loading spinner if we are refreshing the cache
const isLoading =
managersStatus !== Status.SUCCESS && (!managers || managers.length === 0)

const handleRemoveManager = useCallback(
(params: { userId: number; managerUserId: number }) => {
Expand Down Expand Up @@ -72,7 +79,7 @@ export const AccountsManagingYouHomePage = (
</Button>
</Flex>
<Flex direction='column' gap='s'>
{managersStatus !== Status.SUCCESS ? (
{isLoading ? (
<Box pv='2xl'>
<LoadingSpinner
css={({ spacing }) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ export const AccountsYouManageHomePage = ({
const userId = currentUser?.user_id
const { data: managedAccounts, status } = useGetManagedAccounts(
{ userId: userId! },
{ disabled: userId == null }
// Always update managed accounts list when mounting this page
{ disabled: userId == null, force: true }
)
// Don't flash loading spinner if we are refreshing the cache
const isLoading =
status !== Status.SUCCESS &&
(!managedAccounts || managedAccounts.length === 0)
const [approveManagedAccount, approveResult] = useApproveManagedAccount()
const [rejectManagedAccount, rejectResult] = useRemoveManager()
const { toast } = useContext(ToastContext)
Expand Down Expand Up @@ -95,7 +100,7 @@ export const AccountsYouManageHomePage = ({
<Text variant='body' size='l'>
{messages.takeControl}{' '}
</Text>
{status !== Status.SUCCESS ? (
{isLoading ? (
<Box pv='2xl'>
<LoadingSpinner
css={({ spacing }) => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useCallback, useEffect, useState } from 'react'

import { Button, IconUserArrowRotate } from '@audius/harmony'
import { useLocation } from 'react-router-dom'

import { useHistoryContext } from 'app/HistoryProvider'
import { ACCOUNTS_YOU_MANAGE_SETTINGS_PAGE, doesMatchRoute } from 'utils/route'

import SettingsCard from '../SettingsCard'
Expand All @@ -18,17 +18,14 @@ const messages = {

export const AccountsYouManageSettingsCard = () => {
const [isModalOpen, setIsModalOpen] = useState(false)
const { history } = useHistoryContext()
const location = useLocation()

useEffect(() => {
const match = doesMatchRoute(
history.location,
ACCOUNTS_YOU_MANAGE_SETTINGS_PAGE
)
const match = doesMatchRoute(location, ACCOUNTS_YOU_MANAGE_SETTINGS_PAGE)
if (match) {
setIsModalOpen(true)
}
}, [history.location])
}, [location])

const handleOpen = useCallback(() => {
setIsModalOpen(true)
Expand Down