@@ -7,18 +7,14 @@ import { useQuery } from '@apollo/client'
7
7
import { UserListRow } from '@/components/user-list'
8
8
import Link from 'next/link'
9
9
import AddIcon from '@/svgs/add-fill.svg'
10
- import { MultiAuthErrorBanner } from '@/components/banners'
11
10
import { cookieOptions , MULTI_AUTH_ANON , MULTI_AUTH_LIST , MULTI_AUTH_POINTER } from '@/lib/auth'
12
11
13
12
const AccountContext = createContext ( )
14
13
15
- const CHECK_ERRORS_INTERVAL_MS = 5_000
16
-
17
14
const b64Decode = str => Buffer . from ( str , 'base64' ) . toString ( 'utf-8' )
18
15
19
16
export const AccountProvider = ( { children } ) => {
20
17
const [ accounts , setAccounts ] = useState ( [ ] )
21
- const [ errors , setErrors ] = useState ( [ ] )
22
18
const [ selected , setSelected ] = useState ( null )
23
19
24
20
const updateAccountsFromCookie = useCallback ( ( ) => {
@@ -38,38 +34,20 @@ export const AccountProvider = ({ children }) => {
38
34
return switchSuccess
39
35
} , [ updateAccountsFromCookie ] )
40
36
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
-
55
37
useEffect ( ( ) => {
56
38
if ( SSR ) return
57
39
58
40
updateAccountsFromCookie ( )
59
41
60
42
const { [ MULTI_AUTH_POINTER ] : pointerCookie } = cookie . parse ( document . cookie )
61
43
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 ] )
66
45
67
46
const value = useMemo (
68
47
( ) => ( {
69
48
accounts,
70
49
selected,
71
- nextAccount,
72
- multiAuthErrors : errors
50
+ nextAccount
73
51
} ) ,
74
52
[ accounts , selected , nextAccount ] )
75
53
return < AccountContext . Provider value = { value } > { children } </ AccountContext . Provider >
@@ -119,23 +97,9 @@ const AccountListRow = ({ account, ...props }) => {
119
97
}
120
98
121
99
export default function SwitchAccountList ( ) {
122
- const { accounts, multiAuthErrors } = useAccounts ( )
100
+ const { accounts } = useAccounts ( )
123
101
const router = useRouter ( )
124
102
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
-
139
103
// can't show hat since the streak is not included in the JWT payload
140
104
return (
141
105
< >
0 commit comments