Skip to content

Commit 78b3900

Browse files
committed
Remove multi auth error checking
1 parent 66608a4 commit 78b3900

File tree

2 files changed

+3
-61
lines changed

2 files changed

+3
-61
lines changed

components/account.js

+3-39
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@ import { useQuery } from '@apollo/client'
77
import { UserListRow } from '@/components/user-list'
88
import Link from 'next/link'
99
import AddIcon from '@/svgs/add-fill.svg'
10-
import { MultiAuthErrorBanner } from '@/components/banners'
1110
import { cookieOptions, MULTI_AUTH_ANON, MULTI_AUTH_LIST, MULTI_AUTH_POINTER } from '@/lib/auth'
1211

1312
const AccountContext = createContext()
1413

15-
const CHECK_ERRORS_INTERVAL_MS = 5_000
16-
1714
const b64Decode = str => Buffer.from(str, 'base64').toString('utf-8')
1815

1916
export const AccountProvider = ({ children }) => {
2017
const [accounts, setAccounts] = useState([])
21-
const [errors, setErrors] = useState([])
2218
const [selected, setSelected] = useState(null)
2319

2420
const updateAccountsFromCookie = useCallback(() => {
@@ -38,38 +34,20 @@ export const AccountProvider = ({ children }) => {
3834
return switchSuccess
3935
}, [updateAccountsFromCookie])
4036

41-
const checkErrors = useCallback(() => {
42-
const {
43-
[MULTI_AUTH_LIST]: listCookie,
44-
[MULTI_AUTH_POINTER]: pointerCookie
45-
} = cookie.parse(document.cookie)
46-
47-
const errors = []
48-
49-
if (!listCookie) errors.push(`${MULTI_AUTH_LIST} cookie not found`)
50-
if (!pointerCookie) errors.push(`${MULTI_AUTH_POINTER} cookie not found`)
51-
52-
setErrors(errors)
53-
}, [])
54-
5537
useEffect(() => {
5638
if (SSR) return
5739

5840
updateAccountsFromCookie()
5941

6042
const { [MULTI_AUTH_POINTER]: pointerCookie } = cookie.parse(document.cookie)
6143
setSelected(pointerCookie === MULTI_AUTH_ANON ? USER_ID.anon : Number(pointerCookie))
62-
63-
const interval = setInterval(checkErrors, CHECK_ERRORS_INTERVAL_MS)
64-
return () => clearInterval(interval)
65-
}, [updateAccountsFromCookie, checkErrors])
44+
}, [updateAccountsFromCookie])
6645

6746
const value = useMemo(
6847
() => ({
6948
accounts,
7049
selected,
71-
nextAccount,
72-
multiAuthErrors: errors
50+
nextAccount
7351
}),
7452
[accounts, selected, nextAccount])
7553
return <AccountContext.Provider value={value}>{children}</AccountContext.Provider>
@@ -119,23 +97,9 @@ const AccountListRow = ({ account, ...props }) => {
11997
}
12098

12199
export default function SwitchAccountList () {
122-
const { accounts, multiAuthErrors } = useAccounts()
100+
const { accounts } = useAccounts()
123101
const router = useRouter()
124102

125-
const hasError = multiAuthErrors.length > 0
126-
127-
if (hasError) {
128-
return (
129-
<>
130-
<div className='my-2'>
131-
<div className='d-flex flex-column flex-wrap mt-2 mb-3'>
132-
<MultiAuthErrorBanner errors={multiAuthErrors} />
133-
</div>
134-
</div>
135-
</>
136-
)
137-
}
138-
139103
// can't show hat since the streak is not included in the JWT payload
140104
return (
141105
<>

components/banners.js

-22
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { useMutation } from '@apollo/client'
66
import { WELCOME_BANNER_MUTATION } from '@/fragments/users'
77
import { useToast } from '@/components/toast'
88
import Link from 'next/link'
9-
import AccordianItem from '@/components/accordian-item'
109

1110
export function WelcomeBanner ({ Banner }) {
1211
const { me } = useMe()
@@ -124,24 +123,3 @@ export function AuthBanner () {
124123
</Alert>
125124
)
126125
}
127-
128-
export function MultiAuthErrorBanner ({ errors }) {
129-
return (
130-
<Alert className={styles.banner} key='info' variant='danger'>
131-
<div className='fw-bold mb-3'>Account switching is currently unavailable</div>
132-
<AccordianItem
133-
className='my-3'
134-
header='We have detected the following issues:'
135-
headerColor='var(--bs-danger-text-emphasis)'
136-
body={
137-
<ul>
138-
{errors.map((err, i) => (
139-
<li key={i}>{err}</li>
140-
))}
141-
</ul>
142-
}
143-
/>
144-
<div className='mt-3'>To resolve these issues, please sign out and sign in again.</div>
145-
</Alert>
146-
)
147-
}

0 commit comments

Comments
 (0)