auth modals fix logic (#420)

auth modals fix logic
This commit is contained in:
Ilya Y 2024-02-27 17:42:54 +03:00 committed by GitHub
parent 8b066104e6
commit b1b3f8b435
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 11 additions and 20 deletions

View File

@ -94,10 +94,6 @@ export const App = (props: Props) => {
const is404 = createMemo(() => props.is404) const is404 = createMemo(() => props.is404)
createEffect(() => { createEffect(() => {
if (!searchParams().m) {
hideModal()
}
const modal = MODALS[searchParams().m] const modal = MODALS[searchParams().m]
if (modal) { if (modal) {
showModal(modal) showModal(modal)

View File

@ -19,13 +19,6 @@ type Props = {
const PAGE_SIZE = 20 const PAGE_SIZE = 20
// TODO: проверить нет ли дубликатов в базе данных, если нет - то не использовать addUniqueAuthors()
const addUniqueAuthors = (prevAuthors: Author[], newAuthors: Author[]) => {
const uniqueNewAuthors = newAuthors.filter(
(newAuthor) => !prevAuthors.some((prevAuthor) => prevAuthor.id === newAuthor.id),
)
return [...prevAuthors, ...uniqueNewAuthors]
}
export const AuthorsList = (props: Props) => { export const AuthorsList = (props: Props) => {
const { t } = useLocalize() const { t } = useLocalize()
const { isOwnerSubscribed } = useFollowing() const { isOwnerSubscribed } = useFollowing()
@ -44,9 +37,9 @@ export const AuthorsList = (props: Props) => {
}) })
if (queryType === 'shouts') { if (queryType === 'shouts') {
setAuthorsByShouts((prev) => addUniqueAuthors(prev, result)) setAuthorsByShouts((prev) => [...prev, ...result])
} else { } else {
setAuthorsByFollowers((prev) => addUniqueAuthors(prev, result)) setAuthorsByFollowers((prev) => [...prev, ...result])
} }
setLoading(false) setLoading(false)
} }

View File

@ -53,7 +53,6 @@ export const RegisterForm = () => {
const handleSubmit = async (event: Event) => { const handleSubmit = async (event: Event) => {
event.preventDefault() event.preventDefault()
if (passwordError()) { if (passwordError()) {
setValidationErrors((errors) => ({ ...errors, password: passwordError() })) setValidationErrors((errors) => ({ ...errors, password: passwordError() }))
} else { } else {
@ -102,7 +101,7 @@ export const RegisterForm = () => {
redirect_uri: window.location.origin, redirect_uri: window.location.origin,
} }
const { errors } = await signUp(opts) const { errors } = await signUp(opts)
if (errors) return if (errors.length > 0) return
setIsSuccess(true) setIsSuccess(true)
} catch (error) { } catch (error) {
console.error(error) console.error(error)
@ -134,7 +133,6 @@ export const RegisterForm = () => {
), ),
})) }))
break break
case 'verified': case 'verified':
setValidationErrors((prev) => ({ setValidationErrors((prev) => ({
email: ( email: (

View File

@ -96,7 +96,6 @@ export const SendResetLinkForm = () => {
placeholder={t('Email')} placeholder={t('Email')}
onInput={(event) => handleEmailInput(event.currentTarget.value)} onInput={(event) => handleEmailInput(event.currentTarget.value)}
/> />
<label for="email">{t('Email')}</label> <label for="email">{t('Email')}</label>
<Show when={isUserNotFound()}> <Show when={isUserNotFound()}>
<div class={styles.validationError}> <div class={styles.validationError}>

View File

@ -122,7 +122,13 @@ export const SessionProvider = (props: {
m: 'auth', m: 'auth',
access_token, access_token,
}) })
else if (token) changeSearchParams({ mode: 'change-password', modal: 'auth', token }) else if (token) {
changeSearchParams({
mode: 'change-password',
m: 'auth',
token,
})
}
}) })
// load // load
@ -207,7 +213,6 @@ export const SessionProvider = (props: {
if (session()) { if (session()) {
const token = session()?.access_token const token = session()?.access_token
if (token) { if (token) {
// console.log('[context.session] token observer got token', token)
if (!inboxClient.private) { if (!inboxClient.private) {
apiClient.connect(token) apiClient.connect(token)
notifierClient.connect(token) notifierClient.connect(token)
@ -333,7 +338,6 @@ export const SessionProvider = (props: {
const response = await authorizer().graphqlQuery({ const response = await authorizer().graphqlQuery({
query: `query { is_registered(email: "${email}") { message }}`, query: `query { is_registered(email: "${email}") { message }}`,
}) })
// console.log(response)
return response?.data?.is_registered?.message return response?.data?.is_registered?.message
} catch (error) { } catch (error) {
console.warn(error) console.warn(error)

View File

@ -25,6 +25,7 @@ export type PageProps = {
export type RootSearchParams = { export type RootSearchParams = {
m: string // modal m: string // modal
lang: string lang: string
token: string
} }
export type LayoutType = 'article' | 'audio' | 'video' | 'image' | 'literature' export type LayoutType = 'article' | 'audio' | 'video' | 'image' | 'literature'